Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. # Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].
  2. #Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it.
  3.  
  4. a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
  5. b = [x for x in a if x % 2 == 0]
  6. print(a)
  7. print(b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement