def con(x):
if x==3:
continue #会报错
def con2(x):
if x == 4:
continue #会报错
for i in range(0,10):
con(i)
con2(i)
print(i)
What I mean is that if the conditions in def are met, the externally called for loop will continue. For example, in the example, if the value of i is 3 or 4, continue. Because there are many def methods called in for, and the actual scenario is much more complicated than the example, it feels like it is not very concise to judge the return value one by one. I would like to ask you if there is any way to realize this request of my brother. Thank you very much~
You can affect the for loop by throwing a specific exception:
continue must be used together with for. You can try another implementation idea
such as: