def factorial(n): if n <= 1: return 1 else: return n * factorial(n-1) def printList(L): # If it is empty do nothing if not L: return # If it's a list call printList on 1st element if type(L[0]) == type([]): printList(L[0]) else: # No list so just print print L[0] # Now process the rest of L printList(L[1:])