Advertisement
Guest User

Left and Right Sum

a guest
Feb 8th, 2020
1,229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. n = int(input())
  2.  
  3. sum_left = 0
  4. sum_right = 0
  5.  
  6. for i in range(2 * n):
  7.     num = int(input())
  8.  
  9.     if i < n:
  10.         sum_left += num
  11.     else:
  12.         sum_right += num
  13.  
  14. if sum_left == sum_right:
  15.     print(f'Yes, sum = {sum_left}')
  16. else:
  17.     print(f'No, diff = {abs(sum_left - sum_right)}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement