Syntax error for print

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Dec 25 13:58:14 EST 2008


On Dec 25, 7:53 pm, jsm4... at gmail.com wrote:
> IDLE 3.0>>> print "hello"
>
> SyntaxError: invalid syntax (<pyshell#0>, line 1)>>> 3+3
> 6
> >>> var = 4
> >>> var = var*4
> >>> print var
>
> SyntaxError: invalid syntax (<pyshell#5>, line 1)
>
>
>
> Any idea on why I am getting this error.
> I have just started learning python and I am stuck at first thing
> itself.
> Any help would be greatly appreciated.
>
> Thanks,
> Jeetu Sahil

The print of Python3 needs parentheses:

print(var)

Older Python versions are different.

Bye,
bearophile



More information about the Python-list mailing list