Syntax error, unknown reason...

This is the place for queries that don't fit in any of the other categories.

Syntax error, unknown reason...

Postby bissell44 » Wed Mar 27, 2013 4:27 pm

So whenever I write a program in Notepad++, save it as a .py file, and try to run it with command prompt, it always give me a syntax error. This error is usually on the last character of the last method. For example, something as simple as:

print "Hello world!"

would give me this:

file "pyhelloworld.py", line 1
print "Hello world!"
(with the little arrow pointing up at the last quotation mark, after the exclamation point)
SyntaxError: invalid syntax

Any ideas as to why this is happening?
bissell44
 
Posts: 3
Joined: Wed Mar 27, 2013 4:20 pm

Re: Syntax error, unknown reason...

Postby tnknepp » Wed Mar 27, 2013 5:18 pm

Are you using Python 3.x?
Python: 2.7 via Anaconda
Numpy: 1.7
Pandas: 0.11
OS: Windows 7
IDE: Spyder/IPython
User avatar
tnknepp
 
Posts: 123
Joined: Mon Mar 11, 2013 7:41 pm

Re: Syntax error, unknown reason...

Postby bissell44 » Wed Mar 27, 2013 5:37 pm

yeah, i downloaded it last night straight from python.org/download
bissell44
 
Posts: 3
Joined: Wed Mar 27, 2013 4:20 pm

Re: Syntax error, unknown reason...

Postby Yoriz » Wed Mar 27, 2013 5:41 pm

In python 3 print needs brackets
Code: Select all
print("Hello world!")
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 871
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: Syntax error, unknown reason...

Postby bissell44 » Wed Mar 27, 2013 6:18 pm

Thank you, that seems to have solved the problem. I'm going to switch back to 2.7 though, because that's the language that I'm learning from codecademy.com lol.
bissell44
 
Posts: 3
Joined: Wed Mar 27, 2013 4:20 pm


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 5 guests