Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. def print_nested_list(input):
  2. """Prints out every single string in input, one per line."""
  3. if type(input) is list
  4. for item in input
  5.  
  6. print_nested_list(['cs1110'])
  7. print_nested_list(['this', ['is', 'a'], 'list', ['list', 'list' ]])
  8. print_nested_list([[['cs1110', 'opython'], 'nested'], 'recursion', 'test'])
  9.  
  10. cs1110
  11. opython
  12. nested
  13. recursion
  14. test
  15.  
  16. def print_nested_list(input_list):
  17. if type(input_list) is list:
  18. for item in input_list:
  19. print_nested_list(item)
  20. else:
  21. print input_list
  22.  
  23. mylist = [[['cs1110', 'opython'], 'nested'], 'recursion', 'test']
  24. print_nested_list(mylist)
  25.  
  26. cs1110
  27. opython
  28. nested
  29. recursion
  30. test
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement