How to go back after entering a code

It looks like you are doing it in the command line interface, which is normal for the command line interface. If you want to go back and change your previous code, you should edit it in a text editor or a specialized text editor like Code, Vim, Jupyter, etc.