[Tutor] Please Help me with this.

alan.gauld@bt.com alan.gauld@bt.com
Fri, 22 Oct 1999 11:04:03 +0100


> >         a, b = 0, 1
> >         while b < 10:
> >                    print b
> >                    a, b = b, a+b

> > When I try this:
> > a = 0
> > b = 0
> > while b < 10:
> >           print b
> >           a = b
> >           b = a + b

This is not equivalenmt to the above. You must do:

a = 0
b = 1
while b< 10
	print b
	c = a 	# need a temporary variable
	a = b 	# coz we change a here
	b = c+b 	# and need to use the original value of a here

Alan G.