Advertisement
horozov86

09. Left and Right Sum

Oct 4th, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. number_of_lines = int(input())
  2.  
  3. left_sum = 0
  4. right_sum = 0
  5.  
  6. for num in range(number_of_lines):
  7.     current_number = int(input())
  8.     left_sum += current_number
  9.  
  10. for num in range(number_of_lines):
  11.     current_number = int(input())
  12.     right_sum += current_number
  13.  
  14. if left_sum == right_sum:
  15.  
  16.     print(f"Yes, sum = {left_sum}")
  17. else:
  18.     diff = abs(left_sum - right_sum)
  19.     print(f"No, diff = {diff}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement