+ 1
Python idle shell cannot indent like on code playground
Hi, I am at the following else-statement. x = 4 if x == 5: print("Yes") else: print("No") It runs on the code playground interface. However, when I use the Idle Python shell, it doesn't run. I can't get the "else" statement to next properly. I get an "invalid syntax" message. Any ideas? Thanks
3 Respostas
+ 1
I think you will have to manually Ident it
+ 1
The indents have to be the same size in your code. And you can't mix tabs and spaces.
To have less problems with indents either try using Eclipse+PyDev. It has an auto-fix indents option. Or use reindent:
pip install reindent
reindent <file>
0
Don't use the shell window! Open a new file and try it there. If it doesn't work there, I don't know how to help...