Advertisement
Spocoman

05. Even Numbers

Jan 28th, 2022
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. numbers = list(map(int, input().split(' ')))
  2.  
  3.  
  4. def even_num():
  5.     filtered = []
  6.    
  7.     for i in range(0, len(numbers)):
  8.         if numbers[i] % 2 == 0:
  9.             filtered.append(numbers[i])
  10.            
  11.     return filtered
  12.  
  13.  
  14. print(even_num())
  15.  
  16.  
  17. Решение с ламбда:
  18.  
  19. numbers = list(map(int, input().split(' ')))
  20.  
  21.  
  22. def even_num():
  23.     return list(filter(lambda x: x % 2 == 0, numbers))
  24.  
  25.  
  26. print(even_num())
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement