(no subject)

Doug Stanfield DOUGS at oceanic.com
Fri Jun 22 21:10:27 EDT 2001


To prove its possible, here's my interactive session.  Some comments are
interspersed in yours below:

Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201
(egcs-1.1.1  on linux2Copyright 1991-1995 Stichting Mathematisch Centrum,
Amsterdam
>>> a, b = 0, 1
>>> while b < 1000:
...   print b,
...   a,b = b, a+b
... 
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
>>> 

[crombie ]
> newbie question:
> trying to type this in:
> >>> a, b = 0, 1
> >>> while b < 1000:
> ...     print b,
> ...     a, b = b, a+b
> ... 
> 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
> 
> 
> but result is this:
> >>> while b< 10
> SyntaxError: invalid syntax
> >>> while b < 10:
> ... print b
> IndentationError: expected an indented block (line 2)
> >>> while b < 10:
> 	print b
> 	a, b = b, a+b ...
> 	
> SyntaxError: invalid syntax
> >>> while b < 1000:
> ...	print b,
> IndentationError: expected an indented block (line 2)
> >>> while b < 1000:
>    ...	print b,
>    
> SyntaxError: invalid syntax
> >>> 
> 
> anyone know why?


To me it looks like you might have messed up understanding what is your
input versus what is the computer output in the example you're copying.  To
try to illustrate I'll put square brackets around the output of the
interpreter and indicate other key presses by enclosing them in <>.
Particularly notice the spaces.  I hope its not too confusing:

[Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201
(egcs-1.1.1  on linux2Copyright ][1991-1995 Stichting Mathematisch Centrum,
Amsterdam]
[>>> ]a, b = 0, 1<return>
[>>> ]while b < 1000:<return>
[... ]  print b,<return>
[... ]  a,b = b, a+b<return>
[... ]<return>
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
 
> much thx, tc
> 
HTH,

-Doug-




More information about the Python-list mailing list