Advertisement
elena1234

Filter and list comprehension ( in Python )

Feb 3rd, 2022
2,179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. text = input().split(" ")
  2.  
  3. result = [element for element in text if len(element) % 2 == 0]
  4. print(result)
  5.  
  6. result2 = list(filter((lambda x: len(x) % 2 == 0), text))
  7. print(result2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement