+ 2

What is alternative to goto from C++ in Python?

Sorry for my bad English, I know, there in C++ goto, but what is alternative to goto from C++ aviable in python?

24th Jun 2018, 8:15 AM
Mykhailo Stetsiuk
Mykhailo Stetsiuk - avatar
3 Answers
+ 2
Ah, in Python there is no goto or labels. This StackOverflow answer has more info https://stackoverflow.com/a/41768438 You can define a variable outside a function so that it can be used in multiple places, so global yes.
24th Jun 2018, 8:28 AM
Dan Walker
Dan Walker - avatar
+ 1
goto is typically used to jump to a section of code that we will possibly reuse several times. There is a better way if jumping to a predefined block of code - it's called a function
24th Jun 2018, 8:20 AM
Dan Walker
Dan Walker - avatar
+ 1
Thx, problem resolved
24th Jun 2018, 2:45 PM
Mykhailo Stetsiuk
Mykhailo Stetsiuk - avatar