Kindly be informed that in an assignment declaration, the right-hand side is constantly evaluated fully before doing the actual setting of variables. So if you do,
x, y = y, x + y
This will evaluates y, and x + y, then sets x to ham and y to spam. I.e., it's like
ham = y
spam = x + y
x = ham
y = spam
By contrast,
x = y
y = x + y
sets x to y, then sets y to x (which == y) plus y, therefore it is same as:
x = y
y = y + y
Want to get certified in Python? Register for this complete Python Training course by Intellipaat.