Python


#1

When using my python, keep in mind im new at this, is there a way to go back on the code that i was writing and redo instead of python just giving me an error and then having to retype my code???


#2

You are able to edit the code as much as you need (assuming we are talking exercise).

Not sure I follow your question. Maybe ellaborate a little more, and include a link to the exercise.


#3

its not in regards to an exercise per say, im talking about the actual python shell.


#4

Are you talking about python's REPL? (read eval print loop)

Python 3.6.0 (default, Feb  4 2017, 23:55:14) 
[GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1 + 1
2
>>> 1 + 1
2
>>> 1 + 1
2
>>>

If running it in a terminal then there might be a program running called readline (or something equivalent) that lets you use up arrow key to go back in history. You might also be able to use Ctrl+P (might not be a thing on windows) for previous and Ctrl+N for next which avoids having to reach all the way to the arrow keys

If you're using IDLE which is typical for beginner windows users then moving the cursor (arrow keys) to a previous line and hitting enter places that line in your current input line

If you want your code to be persistent then write it to file instead and run the file with python