python:how to exit if block during interactive mode

2157 views python

just play with Python, a small question on interactive mode.


  1. enter python interactive mode, following line shows detail on interactive mode List item
  2. >>>flag=True
  3. >>>if flag:
  4. . . .     print("flag is True")
  5. after above step, i WANT to exit the whole if block. but if press enter for above line 4, it will start line with "...", which means still in if block.

question: HOW CAN I exit if block and write sth like the following in interactive mode :

if flag:
    print("flag is True")
print("exit if now ")

answered question

Why do you want to use IDLE? And why only in interactive mode

Press enter again to exit the if block

1 Answer


double Enter will exit the if block in the interactive mode

posted this

Have an answer?


Please login first before posting an answer.