8

Environment:

  • Fedora 27 (GNU/Linux)
  • terminal
  • python3.6.3

I am having problems running this simple lines of code in the python interpreter, this is an only if statement or alone if statement.

n = 5
if n == 4:
    print('n=4')
print('done')

enter image description here

This must print the word "done", but what am I doing wrong?

christianbueno.1
  • 516
  • 1
  • 8
  • 12

1 Answers1

18

The interpreter gives you a line after blocks to leave blank for the interpreter to know your block is over (or to put an else, etc.). Putting something there makes it freak out. Just leave it that line blank and wait for the next >>> before your print('done').

>>> n = 5
>>> if n == 4:
...    print('n=4')
...
>>> print('done')
done
Brett Beatty
  • 5,690
  • 1
  • 23
  • 37
  • well , That makes a lot of sense. My error was the last print , that in reality should be placed in the next _primary prompt_ (>>>). – christianbueno.1 Dec 16 '17 at 01:12