[mdlug] Python Code Question
JeremyBekka C
jrchristophel at gmail.com
Fri Sep 4 22:09:31 EDT 2015
Well, I just figured out what was wrong when I ran the code in Idle. I was
using the interpreter for Python3 not 2.7. When I used the right
interpreter it worked fine. However, I can not figure out what is wong in
the terminal.
On Fri, Sep 4, 2015 at 9:56 PM, JeremyBekka C <jrchristophel at gmail.com>
wrote:
> Hello,
>
> I am trying to learn Python by working through the book "Learning Python
> (3th Edition) - Ascher, Lutz (O'Reilly, 2008)". I have a question regarding
> one of the examples in the book which is using python 2.2. The code is the
> following:
>
> while True:
> reply = raw_input('Enter text:')
> if reply == 'stop' : break
> print int(reply) ** 2
> print 'Bye
>
> When I run this in the Idle interpreter it gives me an error on line 4
> with the int() built-in and says "SyntaxError: invalid syntax".
>
> If I run this in the terminal I get the following:
>
> >>> while True:
> ... reply = raw_input('Enter text:')
> ... if reply == 'stop' : break
> ... print int(reply) ** 2
> ... print 'Bye'
> File "<stdin>", line 5
> print 'Bye'
> ^
> SyntaxError: invalid syntax
>
> Any idea what is wrong here? Iooked up the integer built-in on the python
> website and it did not give me any ideas what is wrong.
>
> Thanks
>
More information about the mdlug
mailing list