Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. def purity(listy):
  2.     pure_listy = []
  3.     for key in listy:
  4.         if key % 2 == 0:
  5.             pure_listy.append(key)
  6.         else:
  7.             print key
  8.     print pure_listy
  9.     return pure_listy
  10.  
  11.  
  12. purity([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
  13. """
  14. output prints:
  15. 1
  16. 3
  17. 5
  18. 7
  19. 9
  20. 11
  21. 13
  22. 15
  23. 17
  24. 19
  25. [2,4,6,8,10,12,14,16,18]
  26. which is exactly what i want but the exercise is telling me
  27. "Your code threw a "'builtin_function_or_method' object has no attribute '__getitem__'" error.
  28. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement