0

How to use goto in Python?

how to use "goto"(like in C) in Python?

26th Nov 2017, 4:40 PM
ramakrishna
ramakrishna - avatar
9 Answers
+ 7
Just out of curiosity - why would you want to do that? You can define functions, classes and objects first, to be able to call them anytime you want. No need to number the lines and addressing them that way...
26th Nov 2017, 4:50 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 7
You exit the loop with 'break' :) Seriously, I started learning programming some 20 years ago with gwbasic and really know what you mean. But this kind of programming logic is waaay too obsolete now, since at least OOP ;)
26th Nov 2017, 4:55 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 6
Even in C, where there is no lambda and no classes, it is bad practice to use goto ^^
26th Nov 2017, 4:53 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
sorry pal python don't have go-to statement here reference https://stackoverflow.com/a/438848/7887883
26th Nov 2017, 4:44 PM
Pavan Kumar T S
Pavan Kumar T S - avatar
0
goto is one of the easy way to come out from multiple nested loops, just I need "goto" to reduce code size
26th Nov 2017, 4:53 PM
ramakrishna
ramakrishna - avatar
- 1
You can't
26th Nov 2017, 5:40 PM
VcC
VcC - avatar