Python Swap

Asked 2 years ago, Updated 2 years ago, 142 views

a = 100
b = 200
print(before 'swap: a = ', a, 'b = ', b)
temp = a
a = b
b = temp
print (after 'swap: a = ', a, 'b = ', b)

'''
Result------------------------------------------------------------------------
Before swap: a = 100 b = 200
After swap: a = 200 b = 100
'''

Can an integer be assigned to an integer? (a=b part)

python swap

2022-09-20 10:18

1 Answers


2022-09-20 10:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.