Skip to content

Commit ae8d50c

Browse files
Merge pull request #1855 from Piombacciaio/master
Update swap.py
2 parents 592947a + f21dc16 commit ae8d50c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

swap.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
# x = input('Enter value of x: ')
66
# y = input('Enter value of y: ')
77

8-
# create a temporary variable and swap the values
9-
temp = x
10-
x = y
11-
y = temp
8+
# Swap the values of x and y without the use of any temporary value
9+
x, y = y, x
1210

1311
print("The value of x after swapping: {}".format(x))
1412
print("The value of y after swapping: {}".format(y))

0 commit comments

Comments
 (0)