def rev(val): if len(val) == 0: return val first = val[0] rest = val[1:] try: return rev(rest) + [first] except TypeError: return rev(rest) + first