Is there any possiblty to swap three numbers in a single statement
Eg :
I want values to be changed as per the following list
a = 20
b = 30
c = 10
Can these values be transferred in a single line?
The user has to provide three inputs that will be assigned the three variables x, y, and z. The values will be later used to get swapped among the variables. In the swapping logic, first, the value of x has been temporarily stored in the variable named temp_var.
$ python
>>> a, b, c = 10, 20, 30
>>> print a, b, c
10 20 30
>>> a, b, c = b, c, a
>>> print a, b, c
20 30 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With