Number 7 syntax ERROR

Peter Otten __peter__ at web.de
Thu Nov 8 09:14:00 EST 2018


NoHaxAllSwagg wrote:

> Hello,
> I have been experiencing difficulty while trying to run scripts on my IDLE
> software, considering that when I run my program, I get an error at the
> top of the page in the “Python 3.7.1” area, highlighting the seven telling
> me that there is a syntax error, in this case, I cant remove that area, so
> I cant run my script, please help Sincerely, Zed

You are probably in the "shell" window. The purpose of that window is to try 
small snippets of Python code, e. g. if you enter

1 + 2 + 3

it will print

6

To run a script you are developing with idle save it and then use
[Run Module] in the [Run] menu, or hit the F5 key.

Example:

Click [File] [New File], enter

print("hello world")

into the window that opens, then click

[File] [Save]

and enter hello.py as the filename. If you followed these instructions and 
hit F5 the "shell" window will appear with something like

===== RESTART: /path/to/hello.py ======
hello world

If you made a mistake in your code, say you forgot the closing " in

print("hello world)

a dialog box describing the syntax error will appear instead.

When you want to run the hello.py script like this

python3.7 hello.py

you have to do that in a shell window of your operating system, not in idle.




More information about the Python-list mailing list