Can't get Python to work

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

mehehe

Thread Starter
Joined
Mar 10, 2010
Messages
18
I downloaded Python for the first time today and went to start compiling a code but when I did, it said there was a Syntax error. it highlighted the "2" in "3.2" at the top of IDLE. I tried deleting the 2 but it did the same thing and highlighted the "." after the "3" instead. Same thing when I tried Python 2.7. Both versions were the Windows x86 MSI Installer. Any ideas?
 

Ent

Trusted Advisor
Joined
Apr 11, 2009
Messages
5,467
First Name
Josiah
I don't know python, and what you're saying may make perfect sense to someone who does. But in my experience if someone wants help with code that won't compile the most helpful thing they can do is provide the code you're using.
 

mehehe

Thread Starter
Joined
Mar 10, 2010
Messages
18
thanks for the reply, Ent. It seems to be occurring with any code I try to run. I've tried:
print("hello, world")
several mathematical codes, like 1+1 and 15+32
and several other codes; all resulted in the same error.
Note: the codes worked in the IDLE shell, the problem comes up when I run the module. Also, here are the details of the two versions of Python I've tried:
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32
and
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32
 

Ent

Trusted Advisor
Joined
Apr 11, 2009
Messages
5,467
First Name
Josiah
Are you including that line at the top of your script?
ie would your file say
Code:
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
print("hello, world")
exit()
as it says in the shell or simply
Code:
print("hello, world")
exit()
You don't need any heading for a python script.
 

mehehe

Thread Starter
Joined
Mar 10, 2010
Messages
18
I've tried it with and without the heading. Without the heading, it highlights the second ">" as the error instead. I've also tried it without any ">"s, and it highlighted "world" instead
 

Ent

Trusted Advisor
Joined
Apr 11, 2009
Messages
5,467
First Name
Josiah
If you create a file in notepad, with only the contents
print("hello, world")
and save that as Hello.py,
can you doubleclick that and run it successfully?
 

mehehe

Thread Starter
Joined
Mar 10, 2010
Messages
18
sorry, I don't know if that means it runs or not (I have zero experience with coding, sorry)
 

Ent

Trusted Advisor
Joined
Apr 11, 2009
Messages
5,467
First Name
Josiah
I don't know enough about Python to tell what's happening. If it's opening with notepad then you probably saved it as a .txt file (such as programname.py.txt). Make sure that you choose "All files" when using Save as under notepad. Other than that I can't be sure.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top