It is necessary to interrupt the loop while inside the function, is it possible? Such code:
def func(): if True: break while True: func() Naturally does not work. Can be replaced by:
def func(): if True: return True while True: if func(): break but this adds an "extra" check to the loop, which is undesirable.
You can refuse to use the function, and just copy the code with the break, but this will turn everything into an unreadable mess. Are there any other options?
Added by:
very roughly the code looks like this: (it is, of course, more, but I don’t know what else could be important)
def func(p1,p2,p3): answer = api(p1,p2,p3) if answer['ответ'] == не_устраивающие_нас_значение: break while True: #что-то считаем if что-то-там: #еще что-то считаем if еще-что-то: func(p1,p2,p3)