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

24th Dec 2016, 12:25 AM
Adeniyi Boluwatife
Adeniyi Boluwatife - avatar
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 ;)
24th Dec 2016, 12:37 AM
visph
visph - avatar
+ 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 ^^
24th Dec 2016, 12:55 AM
visph
visph - avatar
+ 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...
28th Dec 2016, 9:19 PM
visph
visph - avatar
+ 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
24th Dec 2016, 12:51 AM
Rishi Anand
Rishi Anand - avatar
+ 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.
24th Dec 2016, 12:54 AM
Uran Kajtazaj
Uran Kajtazaj - avatar
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.
28th Dec 2016, 8:03 PM
Cory