0
Am having a problem on my windows version of python
if 10 > 5: print("10 greater than 5") print("program ended") syntax error invalid syntax
6 Answers
+ 3
Your code works into Code Playground: the problem isn't in it...
Try to copy paste from your post, towards:
1) the Code Playground and run it
2) a new py file on your pc and execute it
If none works, try to rewrite from scratch ( no copy paste )...
And be sure of your text encoding type... even if I don't think it may be problematic in this case ^^
Finally, attempt to debug ( compare, investigate, and so on... ) and post the result of all of these if you cannot resolve yourself ;)
+ 3
"There maybe one thing, if you are running Python v2 then print is not a function but a statement"
Yep, but the behaviour is in 3.x you can't use print without parenthesis, and in 2 ( only 2.7 ? ), you can with or without ^^
+ 3
It's strange... and probably a bug specific to one windows implementation version of Python, because in code playgroud these lines of code run without error...
+ 2
Where does the syntax invalid points to?
There maybe one thing, if you are running Python v2 then print is not a function but a statement
+ 2
you probably have python 2 installed instead of 3.
try removing the brackets like this
print "10 greater than 5"
print "program ended"
and tell us what is the output.
0
I'm having the same problem on Python 3.5 on my PC. I entered:
if 10 > 5:
print("10 greater than 5")
print("Program ended")
And I get the error:
File "(stdin)", line 3
print("Program ended")
Any help would be great. Thanks.