Advertisement
desislava_topuzakova

09. Left and Right Sum

Oct 3rd, 2020
1,446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. n = int(input())
  2. sum_first = 0
  3. sum_second = 0
  4.  
  5. # първите n числа и ги сумираме
  6. for number in range(1, n + 1):
  7.     value = int(input())
  8.     sum_first += value
  9.  
  10. # вторите n числа и ги сумираме
  11. for number in range(1, n + 1):
  12.     value = int(input())
  13.     sum_second += value
  14.  
  15. if sum_first == sum_second:
  16.     print(f'Yes, sum = {sum_first}')
  17. else:
  18.     print(f'No, diff = {abs(sum_first - sum_second)}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement