I’m pretty new at python and I was wondering if this:
def func(self, foo):
for foo in self.list:
if foo.boolfunc(): return True
return False
is good practice.
Can I return out of a loop like the above or should i use a while-loop, like so?
def func(self, foo):
found = false
while(not found & i < len(self.list)):
found = foo.boolfunc()
++i
return found
My java-professor warns us never to use breaks in our loops, but this technically isn’t a break and it’s more concise, so… yeah
thanks
There’s nothing wrong with your example, but it’s better to write