python program to swap two variables | python program to swap two variables using temporary variables |
Python program to swap two variables
In this program swap two variables it is generally done by using a temporary variable.
python program to swap two variables |
Program -
x = input('Enter value of x: ')
y = input('Enter value of y: ')
temp = x
x = y
y = temp
print('The value of x after swapping: ',x)
print('The value of y after swapping: ',y)
output
Enter value of x: 3
Enter value of y: 4
The value of x after swapping: 4
The value of y after swapping: 3
Enter value of y: 4
The value of x after swapping: 4
The value of y after swapping: 3
Post a Comment