# String reverse done recursively # Matt Bishop, Mar. 8, 2012 # for ECS 10 Winter 2012 # function to reverse string # parameter: s, a string # returns: s reversed def reverse(s): # base case: string with 0 elements if s == "": return "" # recursion here: reverse rest, append first else: return reverse(s[1:]) + s[0]