def rev_recursive(li): try: iterator = iter(li) except TypeError: return li l = [] for item in iterator: item = rev_recursive(item) l = [item] + l return l