def f():
return break
for i in range(10):
f()
File "<ipython-input-2-24d25cc18b48>", line 2
return break
^
SyntaxError: invalid syntax
how should I do
use function return berak in for loop
I'm guessing what you want to do is something like this:
def f():
return True
for i in range(10):
if f():
break
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.