On 05/01/16 00:37, yehudak . wrote:
> In Python we can swap values between two variable a and b this way:
>
> a = 3; b = 7
> print(a, b) # => 3 7
>
> a, b = b, a # swapping!
> print(a, b) # => 7 3
>
> How does this work?
Steven has given you a detailed answer showing how Python d
On Tue, Jan 05, 2016 at 02:37:27AM +0200, yehudak . wrote:
> In Python we can swap values between two variable a and b this way:
>
> a = 3; b = 7
> print(a, b) # => 3 7
>
> a, b = b, a # swapping!
> print(a, b) # => 7 3
>
> How does this work?
The right-hand side of the assignmen
In Python we can swap values between two variable a and b this way:
a = 3; b = 7
print(a, b) # => 3 7
a, b = b, a # swapping!
print(a, b) # => 7 3
How does this work?
If I split the 'magic' line into:
a = b; b = a
without a temp variable I get:
print(a, b) # => 7 7
Thank