Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = input('Enter x: ')
- y = input('Enter y: ')
- x = int(x)
- y = int(y)
- count = 0
- last = 0
- a = x
- b = y
- while x > 0 or y > 0:
- if x % 10 + y % 10 + last > 9:
- count = count + 1
- last = 1
- else:
- last = 0
- x = x // 10
- y = y // 10
- if count == 0:
- print(a,' + ',b,' has no carries.')
- elif count == 1:
- print(a,' + ',b,' has one carry.')
- else:
- print(a,' + ',b,' has ',count,' carries.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement