Advertisement
GeorgiLukanov87

fsfasfs

Apr 3rd, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. num1 = int(input())
  2. num2 = int(input())
  3. is_all_number_printed = False
  4. for number in range(num1, num2 + 1):
  5.     number_str = str(number)
  6.     odd_sum = 0
  7.     even_sum = 0
  8.     for position, current_digit_in_number in enumerate(number_str):     # position = 0 (1st position)
  9.         if position % 2 == 0:                                           # position = 1 (2nd position)
  10.             odd_sum += int(current_digit_in_number)                     # position = 2 (3th position)
  11.         elif position % 2 != 0:                                         # pos..etc = 5 (6th position)
  12.             even_sum += int(current_digit_in_number)
  13.     if even_sum == odd_sum:
  14.         print(number, end=' ')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement