Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 06. Odd Even Sum
- n = int(input())
- even_sum = 0
- odd_sum = 0
- for position in range(1 , n+1):
- current_num = int(input())
- if position % 2 == 0:
- even_sum += current_num
- else:
- odd_sum += current_num
- if even_sum == odd_sum:
- print(f"Yes")
- print(f"sum = {even_sum}")
- else:
- diff = abs(even_sum - odd_sum)
- print(f"No")
- print(f"diff = {diff}")
Add Comment
Please, Sign In to add comment