Advertisement
aneliabogeva

Odd/Even possistion sum

May 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. n = int(input())
  2.  
  3. even_sum = 0
  4. odd_sum = 0
  5.  
  6. for i in range(1, n+1):
  7. current_num = int(input())
  8. if i % 2 == 0:
  9. odd_sum += current_num
  10. else:
  11. even_sum += current_num
  12. if even_sum == odd_sum:
  13. print(f"Yes")
  14. print(f"Sum = {odd_sum}")
  15. else:
  16. print("No")
  17. print(f"Diff = {abs(odd_sum-even_sum)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement