Advertisement
GalinaKG

04. Odd and Even Sum

Jun 11th, 2022
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. def odd_even_sum(nums):
  2.     odd_sum = 0
  3.     even_sum = 0
  4.     for num in nums:
  5.         if num % 2 == 0:
  6.             even_sum += num
  7.         else:
  8.             odd_sum += num
  9.  
  10.     print(f'Odd sum = {odd_sum}, Even sum = {even_sum}')
  11.  
  12.  
  13. numbers = map(int, list(input()))
  14. odd_even_sum(numbers)
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement