Python idle shell cannot indent like on code playground | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

27th Nov 2016, 3:04 PM
Cindy Anderson
Cindy Anderson - avatar
3 Answers
+ 1
I think you will have to manually Ident it
27th Nov 2016, 3:08 PM
Sandeep Chatterjee
+ 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>
28th Nov 2016, 1:27 PM
donkeyhot
donkeyhot - avatar
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...
28th Jul 2017, 1:29 AM
Wolfy Mountain
Wolfy Mountain - avatar