[Tutor] New to Python - print function - invalid syntax

Greg Markham greg.markham at gmail.com
Tue Aug 5 01:44:46 CEST 2014


On Mon, Aug 4, 2014 at 11:52 AM, Joel Goldstick <joel.goldstick at gmail.com>
wrote:

> On Mon, Aug 4, 2014 at 1:28 PM, Greg Markham <greg.markham at gmail.com>
> wrote:
> > Hello,
> >
> > I'm extremely new to Python having only just started learning this week.
> > I'm slowly plodding through a book, Python Programming for the Absolute
> > Beginner, 3rd ed by Michael Dawson.
> >
> > Code is provided for all the scripts found throughout the book (found
> here),
> > but I'm running into a syntax error when running one of the unmodified
> > programs.  On line 14, which reads:
> >
> > print("Here", end=" ")
> >
> > I'm receiving a syntax error which points to the end parameter.  In
> order to
> > confirm this, I modified the code to read:
> >
> > print("Here ")
> >
> > ...which runs without incident.  My best guess is that there's a minor
> > difference between the version of Python I'm using (3.4.1) and that which
> > was in use at the time the book was written (3.1.x) that is responsible
> for
> > this error.
>
> Welcome to the group.  I think you made a typo.  Your code should run.
> I just tried this:
> >>> print("hi", end=" ")
> hi >>>
>

 Ok, when I try this from the Shell window, it works.  When executing the
full program from command line, it does not.  Python versions from both
shell and command line are 3.4.1 (confirmed via command: "python -V").

Full error msg output when run from cmd line reads:

  File "I:\Programming\Scripts\Learning\chapter02\game_over2.py", line 14
    print("Here", end=" ")
                     ^
SyntaxError: invalid syntax

A couple of things that will make it easier to help:
>
> 1. send mail as plain text.  Rich text causes some readers problems
>

Thanks for the tip.  I'll keep this in mind for future queries & replies.


> 2. copy and paste the code and complete traceback.  retyping things
> make it more likely that what is in your code isn't exactly what you
> typed
>

Apologies, but what is a traceback?  Is this a debugging feature found in
the shell?  (I looked, but didn't see it)

Thanks,

Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140804/82bb9722/attachment.html>


More information about the Tutor mailing list