Home > Mobile >  how can Edit a block code after running in python IDLE?
how can Edit a block code after running in python IDLE?

Time:10-11

Im new in python. I run this code:

x=5
y="john"
print(x)

now I need to edit x=5 to x="jack" how can I edit this block code in python IDLE 3.10.7?

CodePudding user response:

You cannot edit/undo a command that has already executed. You can reexecute and modify any lines you've entered in the terminal though by pressing the up-arrow key on your keyboard.

Click once: print(x) should be visible on the terminal.

Click again and: y="john" should be visible. Now you can move the cursor with the 'left/right' arrow keys and replace the y with a x. Press enter.

Now press up two times: print(x) should be visible. When you execute that command you'll see x is "john" now.

Hope that helped. Good luck with python.

CodePudding user response:

The question is ambiguous as to if you are referring to the editor itself or reassignment of values in the code.

If it is the editor, then just open the python file, edit it and save the changes.

If it is changing the values of variables then:

You can reassign a new value or string to a variable like this:

x=5
y="john"
print(x)


# edit variable
x = "jack"
print(x)
  • Related