excanging value of two variable in python

Solutions on MaxInterview for excanging value of two variable in python by the best coders in the world

showing results for - "excanging value of two variable in python"
Finn
20 Jul 2020
1# Python program to swap two variables
2
3x = 5
4y = 10
5
6# To take inputs from the user
7#x = input('Enter value of x: ')
8#y = input('Enter value of y: ')
9
10# create a temporary variable and swap the values
11temp = x
12x = y
13y = temp
14
15print('The value of x after swapping: {}'.format(x))
16print('The value of y after swapping: {}'.format(y))
17