Syntax problem - cannot solve it by myself

Robert Kern robert.kern at gmail.com
Tue Jun 8 17:58:48 EDT 2010


On 6/8/10 5:44 PM, Deadly Dirk wrote:
> I am a total beginner with Python. I am reading a book ("The Quick Python
> Book", 2nd edition, by Vernon Ceder) which tells me that print function
> takes end="" argument not to print newline character. I tried and here is
> what happens:
>
>>>> print(x)
> abc
>>>> print(x,end="")
>    File "<stdin>", line 1
>      print(x,end="")
>                 ^
> SyntaxError: invalid syntax
>>>>
>
> What does the error message mean? I am using Python 2.6.5 on Ubuntu 9.10.

The Quick Python Book is based on Python 3, which is a major upgrade from Python 
2.6 and changed some parts of Python's syntax. In particular, it changed the 
print statement to a print() function.

You can install Python 3 on Ubuntu using the python3 package.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list