Python cannot open the program due to invalid syntax

Asked By 0 points N/A Posted on -


IDLE tries to run shell window if line is completed with F5 rather than Enter and I think this caused an error. I don’t know what I’ve missed and why my syntax is invalid. Any ideas about this error ? What is creating this one ?

Thank you !

Syntax error

There’s an error in your program invalid syntax.

Answered By 574060 points N/A #179485

Python cannot open the program due to invalid syntax


I guess this is a clear syntax error on using the print statement in Python. In the screenshot, the print statement is used as “print ‘print’” where, supposedly, the user wants to print or display the word “print” on the screen. But after executing the command, it returned an error. This is because the print statement is used incorrectly to print the text “print”.

To print or display something on the screen using the print statement, it should be typed in this format:

  • Print “Hello world and Python!”;

The text to be displayed needs to be enclosed inside double quotes then ending the line with a semicolon. If you are using Python 2.4.3, this line or command will display the texts:

  • Hello world and Python!

But if you are using the new version of Python, instead of using the command “print “Hello world and Python!”;”, the texts need to be enclosed inside the parenthesis just like this:

  • Print (“Hello world and Python!”);

So, in your case, to fix the error you encountered in Python when using the print statement, your whole line should be like this:

  • Print (“print”);

Login/Register to Answer

Related Questions