0

i am trying to write 3 lines in python shell. I know i can do this in IDLE and run the .py script but wanted to know if there is a way. I get "unindent does not match any outer indentation level" error. Running in Linux.

for n in range(1,5):
    print(n)
print('cool')

The last line gets the error.

ThomasDKim
  • 305
  • 3
  • 14
  • pip install ptpython, then use it in place of 'python' to enter the REPL. It handles indents and lots of other things more elegantly. – SteveJ Nov 29 '17 at 20:10
  • I've looked at the above link. still not clear. basically after "print(n)" + Enter, the cursor goes to the first position of the next line. I've used both tab and 4 spaces to line up to the first line and it still errors out with either "invalid syntax" or the unindent error. – ThomasDKim Nov 29 '17 at 20:11
  • i am teaching my son to program and stuck with idle3 (KANO)... – ThomasDKim Nov 29 '17 at 20:12
  • not really, the REPL is just as present as Idle. Ptpython just replaces the REPL. Since your question is about the shell -- you will find that it will address your indent issue. Aside from that, the only thing that comes to mind is that you are mixing tabs and spaces. Try again, use only spaces (4) on both the print statements. It works. – SteveJ Nov 29 '17 at 20:39

0 Answers0