I have been wondering for a very long time: "How do I define the end of a function in the console?"
Thanks for any answers.
Do not indent the next line:
def my_func(x): print(x) my_func(1)
@ccc not the interpreter, just the console.
I assume you mean the
>>>prompt? (Some people call that the "interpreter" as well, as opposed to the "normal" Python runtime.) If you enter any multiline code in the interactive prompt, you need to hit Return twice at the end to run it.
It's also important that one multiline "fragment" (terminated by two returns) only contains exactly one Python "block". For example, the following code:
for x in range(5): print(x) for x in range(5, 10): print(x)
is perfectly valid Python code. However if you type it into the interactive prompt exactly like this, you'll get a syntax error at the start of the second
forblock. If you include an extra blank line between the blocks, the code will also be valid in the interactive prompt.
@dgelessus oh thank you. I appreciate it.