Python Language Question?

Paul Symonds Paul.J.Symonds at gmail.com
Sun Feb 27 11:45:58 EST 2011


Can someone give and explanation of what is happening with the following:

>>> a,b = 0,1			# this assigns a = 0 and b = 1

>>> while b < 10:
...     print b
...     a, b = b, a+b
...
1
1
2
3
5
8


>>> a=0
>>> b=1
>>> while b < 1000:
...     print b
...     a = b
...     b = a+b
...
1
2
4
8
16
32
64
128
256
512


Why is this statement ..     a, b = b, a+b
different to ...     a = b
...     			b = a+b





More information about the Python-list mailing list