Swapping variables in python

 Swapping variables in python



Explanation: Assignment(=) in any programming language takes place from right to left so what happens behind the scene? Here in line 9 ; x,y = y,x the swapping takes place the right side i.e left of = signs are evaluated first so y which has the value of second number is assigned to x and the variable x which has the value of first number gets assigned to y.

Comments

Popular posts from this blog

Chapter 05 - File Handling

Dictionary (Python)

Tuple (Python)