Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def result():
- num = input()
- odd_sum = 0
- even_sum = 0
- for i in range(0, len(num)):
- if int(num[i]) % 2 == 1:
- odd_sum += int(num[i])
- else:
- even_sum += int(num[i])
- return f' Odd sum = {odd_sum}, Even sum = {even_sum}'
- print(result())
- Или:
- def result():
- number = [int(i) for i in list(input())]
- odd_sum = sum([num for num in number if num % 2 == 1])
- even_sum = sum([num for num in number if num % 2 == 0])
- return f' Odd sum = {odd_sum}, Even sum = {even_sum}'
- print(result())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement