How do I reference an old line? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I reference an old line?

I am new to python, and I can't figure out how to run a previous line ( ex. run line 7 from line 20). it is like the "goto" function in cmd.

17th May 2017, 8:37 PM
St.Jimmy
2 Answers
+ 1
Make line 7 a function and call it from line 20 or have line 20 end your loop restarting it at line 7 Goto is a very poor way to code Python and it is very much not recommended.. That said, who am I to tell you what you should do with your codes.. a quick search lead me to a Python module that does what you want.. It was designed as an April fool's joke, but It appears it is a real thing and actually functions as goto. http://entrian.com/goto/
17th May 2017, 9:23 PM
LordHill
LordHill - avatar
+ 1
complete the python tutorial, you will learn more about loops and functions etc. you will get the info you need
17th May 2017, 9:44 PM
Daemo
Daemo - avatar