Mon Aug 09 2021

Swapping values

File Name: swap-value-in-python.py

#!/usr/bin/evn python

a = 5
b = 8

print ('Before swap')
print(a, b)

# Tuples: swaps values
a, b = b, a

print ('After swap')
print(a, b)


# ***** Output *****
Before swap
5 8
After swap
8 5
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.