[Tutor] Fibonacci Series
Dave Angel
davea at davea.name
Sun Nov 24 12:33:05 CET 2013
On Sun, 24 Nov 2013 11:24:43 +0100, Rafael Knuth
<rafael.knuth at gmail.com> wrote:
> a, b = b, a +b
> a = b = 1
> b = a + b = 1 + 1 = 2
I suggest you play with the statement a bit. Print out both values
each time through the loop.
The expression b, a+b produces a tuple. The left side a, b *unpacks*
that tuple into the two variables.a and b.
Perhaps a simpler case might help. Try a, b = b, a What would you
expect it to do and why?
--
DaveA
More information about the Tutor
mailing list