S
S
sharkyyy32020-04-29 10:18:33
Python
sharkyyy3, 2020-04-29 10:18:33

How to exit nested loop on certain event?

How do I exit the last loop when I get one eventof the loops above?
After all, after the last cycle starts, the processing of events from the upper cycles stops

longpoll = VkLongPoll(vk_session)
while True:
    for event in longpoll.listen():
        while True:
            #какой-то код

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Korotenko, 2020-04-29
@firedragon

Wrap it in a function and exit on return, another option is to exit on the label using goto

D
Diamond, 2020-04-29
@falmaz

try-except construct can help. To exit by condition, you must throw an exception.
Python Try Except

A
Andriy Zherebnyuk, 2020-04-29
@FLEYZEN

While = False

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question