Python, I have a basic question.

Asked 2 years ago, Updated 2 years ago, 115 views

After the repeat statement is over, shouldn't you exit the repeat statement and run the following...? I wrote it in my heart, but why isn't it working? And how do I get print("a") executed? (This is the cmd window.)

python for

2022-09-22 21:29

1 Answers

From Python REPL

>>> # After this console
... # dotdotdot refers to the block of a function or specific syntax.

Therefore, ... must be followed by proper grammar written on the block.

However, a print("a") without an indent has arrived, so a syntax error occurs.

It's the same for REPL in other languages The role of REPL is to receive a single command and immediately output a return value or log message.

To see the multi-line code working at once, as you intended, You have to fill it out as a file and run it.


2022-09-22 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.