Write a program to swap two numbers using a third variable
x = 1
y = 2
print(f'Before swapping x is {x} and y is {y}.')
temp = x # temp = 1
x = y # x = 2
y = temp # y = 1
print(f'After swapping x is {x} and y is {y}.')
Study more about Python at Python Class 10
1.5k questions
1.4k answers
4 comments
7.3k users