Tuples
I can't understand what the author means in this passage of "How to think like a computer scientist":
"Functions can return tuples as return values. For example, we could write a function that swaps two parameters:
def swap(x, y):
return y, x
Then we can assign the return value to a tuple with two variables:
a, b = swap(a, b)
In this case, there is no great advantage in making swap a function. In fact, there is a danger in trying to encapsulate swap, which is the following tempting mistake:
def swap(x, y): # incorrect version
x, y = y, x

See more answers at brainly.com

Looking for something else?

Not the answer you are looking for? Search for more explanations.

## More answers

Looking for something else?

Not the answer you are looking for? Search for more explanations.