AnkitWebLogic

Swap numbers without using 3rd variable

Exercise 13: WAP to input two numbers and swap them without using a 3rd variable. 1

# Input two numbers and swap them | ankitweblogic.com
a=int(input("Input 1st number:"))
b=int(input("Input 2nd number:"))
a,b=b,a
print("After swapping")
print("A =",a)
print("B =",b)
Input 1st number:10
Input 2nd number:20
After swapping
A = 20
B = 10

Advertisement