N/APosted on - 08/20/2014
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 !
There’s an error in your program invalid syntax.
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:
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: