def reverse_rec(tempstr):
   """ recursively reverses a string and returns it """
   if tempstr == "": #checks if string is empty
      return ''
   else:
      #calls reverse_rec starting from the second element and concatinating the first element to it
      return reverse_rec(tempstr[1:]) + tempstr[0]