I am using IDLE to learn python and I just notices something. Whenever I do a mistake, and press enter key, the program throws a syntax error. That’s fine till now. But why I cannot go back, edit the lines and then re-run the code instead of writing again? I mean:
>>> def func(params):
return ";"
if 1 + 1 == 2 """this will throw a syntax erro when I press enter"""
can’t I just put an indent and continue to code instead of having to write the whole code again?
It’s because you are entering your program into an REPL – Read, Evaluate, Print Loop. As you enter lines, they are being evaluated and the output is printed.
You should write your code in a file, name it MyCode.py or whatever, and then open that with IDLE. You can then call functions inside your file from within IDLE, or execute the whole thing all at once.