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))
The value of x after swapping: 10
The value of y after swapping: 5
admin

admin

Leave a Reply

Your email address will not be published. Required fields are marked *