Advertisement
STANAANDREY

lsd4 hw4

Oct 22nd, 2022
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. from functools import reduce
  2.  
  3.  
  4. def reducer(x, y):
  5.     if y % 2 == 0:
  6.         return x + y
  7.     return x
  8.  
  9.  
  10. lst = [int(item) for item in input("Enter the list items: ").split()]
  11. evenSum = reduce(reducer, lst, 0)
  12. print(evenSum)
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement