Python Program to Swap Two Variables

Spread the love

In This tutorial, you will learn about how write a program to swap two variables in python.

# Python program to swap two variables x = 5 y = 10 # We need to create a temporary variable and swap the values temp = x x = y y = temp print('The value of x after swapping: {}'.format(x)) print('The value of y after swapping: {}'.format(y))