Swap Every Two Digits - WIPRO
Swap Every Two Digits - WIPRO
Problem:
The program must accept two integers X and Y as the input. The program must swap every two digits in both X and Y. Then the program must print the sum of the revised values of X and Y as the output. If the number of digits in an integer is odd, the last digit remains the same as there is no digit to swap.
Input:
27521 7809
Output:
81041
Program:
def swap_two(number):
res = ""
while number != "":
res += number[:2][::-1]
number = number[2:]
return int(res)
a,b = input().split()
a = swap_two(a)
b = swap_two(b)
print(a+b)
Comments
Post a Comment