-5

I have centos 6.5
If I type python, I get:

Python 3.3.2 (default, Oct 30 2013, 08:01:17) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux

I created a file 1.py with:

print "Goodbye, World!"

I do python ./1.py
I get

  File "./1.py", line 1
    print "Goodbye, World!"
                          ^
SyntaxError: invalid syntax
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278

2 Answers2

0

print is a function in python 3, the syntax you've used corresponds to python2.

So, you need to do

print("Goodbye, World!")
Anshul Goyal
  • 73,278
  • 37
  • 149
  • 186
0
print("Goodbye, World!")

print is a function in Python 3

Andy
  • 49,085
  • 60
  • 166
  • 233
  • obviously, not, tis fixed the issue :-) – Itay Moav -Malimovka Aug 01 '14 at 20:08
  • @Ben. [No](https://docs.python.org/3.0/whatsnew/3.0.html): Python 3.0, also known as “Python 3000” or “Py3K”, is the *first ever intentionally backwards incompatible* Python release. – Andy Aug 01 '14 at 20:09
  • @Andy Should I go with 3* branch? I am just learning for fun +pygame – Itay Moav -Malimovka Aug 01 '14 at 20:10
  • @ItayMoav-Malimovka, the general recommendation is that new development should go with Python 3, unless you have to use a library that is in red on this [page](https://python3wos.appspot.com/). Those have not been migrated to Python 3 yet – Andy Aug 01 '14 at 20:11
  • @ItayMoav-Malimovka You might run across [problems like this](http://stackoverflow.com/q/14115440/1860929) if using 3.3, so keep those nitty gritty details in mind. If I were doing it for fun, I would go with python 2.7, because, why would I want to spoil my fun with such stupid issues. – Anshul Goyal Aug 01 '14 at 20:12
  • @ItayMoav-Malimovka, [Pygame 1.9.2 supports Python 3.2 and up. Only the orphaned _movie module (not built by default) does not.](http://www.pygame.org/wiki/FrequentlyAskedQuestions#Does%20Pygame%20work%20with%20Python%203?) – Andy Aug 01 '14 at 20:13
  • Much appreciated all for the help – Itay Moav -Malimovka Aug 01 '14 at 20:13