May-21-2024, 03:17 PM
(This post was last modified: May-21-2024, 03:27 PM by deanhystad.)
There are restrictions on code you can enter in the interpreter. You could enter your program like this:
[output]>>> x = 5
>>> if x < 10:
... print("smaller")
...
smaller
>>> if x > 20:
... print("bigger")
...
>>> print("finis")
finis
The python interpreter changes the prompt between ">>>" and "...". When the prompt is "...", python is telling you that it thinks you are inside an indented block of code, like the body of code following an "if" statement. Enter a blank line to exit the block and get the ">>>" prompt, then you can enter your second "if" statement. The interactive interpreter expects you to enter code one expression at a time.
[output]>>> x = 5
>>> if x < 10:
... print("smaller")
...
smaller
>>> if x > 20:
... print("bigger")
...
>>> print("finis")
finis
The python interpreter changes the prompt between ">>>" and "...". When the prompt is "...", python is telling you that it thinks you are inside an indented block of code, like the body of code following an "if" statement. Enter a blank line to exit the block and get the ">>>" prompt, then you can enter your second "if" statement. The interactive interpreter expects you to enter code one expression at a time.