[mdlug] Python Code Question

cass inator cassinator09 at gmail.com
Fri Sep 4 23:41:55 EDT 2015


Are you specifically calling the python 2.7 when running the program?  Is
Python set on your path? Try double quotes around Bye instead of single?

Good Luck!
On Sep 4, 2015 10:10 PM, "JeremyBekka C" <jrchristophel at gmail.com> wrote:

> 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
> >
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>


More information about the mdlug mailing list