Skip to content
Advertisement

Tag: swap

Is there a standardized method to swap two variables in Python?

In Python, I’ve seen two variable values swapped using this syntax: Is this considered the standard way to swap two variable values or is there some other means by which two variables are by convention most usually swapped? Answer Python evaluates expressions from left to right. Notice that while evaluating an assignment, the right-hand side is evaluated before the left-hand

Advertisement