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
Ask the community — students and mentors are here to help, and you can search past answers too.
Ask a Question arrow_forward