0
Python - Goto? Loops?
I understand thereâs no Goto in Python. How do you make the code go back to a certain point. EG: Type in command: âlistâ (Prints a list) >>> Why I want to do is make the code then go back to the top where it says âtype in commandâ and I can others commands in eg âhelpâ or stuff. I have the commands all coded already.
2 Answers
+ 1
This is an example of a while loop:
X = 5
While x == 5:
Input("write a command: ")
#so while x is equal to 5 the code will keep referring to the indented section again and again
#ps. You will have to replace the apostraphes because my ones are different from what they should be
#pps. Check the indentation, they might be wrong, if they are just add or remove spaces
+ 1
Also, functions play a big role. To jump between places or to execute code more than once, you call a function from the 'mainstream', or all your code is in functions that call each other.