3 ms·
$ python3 foo.py File "~/Desktop/foo.py", line 4 print("Hello world") ^ IndentationError: unindent does not match
by mixmastamyk 4y ago
$ python3 foo.py
File "~/Desktop/foo.py", line 4
print("Hello world")
^
IndentationError: unindent does not match any outer indentation level
I didn't understand your statement exactly, but it doesn't seem to be true in any case.
- compressedgas 4y agoThe file: def foo(): bar = 3 print ('4') runs fine when called as a file but when pasted into Python's REPL results in an error: >>> def foo(): ... bar = 3 ... print ('4') File "<stdin>", line 3 print ('4') ^ SyntaxError: invalid syntax However with a blank line after the definition def foo(): bar = 3 print ('4') results in: >>> def foo(): ... bar = 3 ... >>> print ('4') 4
- mixmastamyk 4y agoI see now. The issue was pasting the snippet into a terminal added an extra level of indentation from the post (pre must be indented). This changed the result.