[Q] Question from Python tutorial

Mark Jackson mjackson at wc.eso.mc.xerox.com
Thu Mar 1 14:50:31 EST 2001


"Young-Jin Lee" <ylee12 at uiuc.edu> writes:
> "Jay O'Connor" <joconnor at cybermesa.com> wrote in message
> news:3A9EA472.F15AF847 at cybermesa.com...
> >
> >
> > Young-Jin Lee wrote:

> > > x.counter = 1
> > > while x.counter < 10:
> > >     x.counter = x.counter * 2
> > > print x.counter
> > >       ^
> > > SyntaxError: invalid syntax

> > You probably cut and pasted the code from the tutorial.  When I cut and

> I typed them manually. I dind't copy and paste.

In the interpreter you need an empty line to signal the end of an
indented code block.  (Code read from a file is scanned completely
before execution, so this hint isn't necessary there).  I think you'll
find that

while x.counter < 10:
    x.counter = x.counter * 2

print x.counter

works just fine. . .

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
    They are the sort of people who think that no observation is
    so intuitive that it can't be improved by regression analysis.
				- Louis Menand





More information about the Python-list mailing list