while True:
... # some code here
if condition:
break
else:
do_something_else_here()
# or
def f():
# some code ...
if condition:
return result_a
else:
do_other_thing()
# ...
return result_b
It's really a comprehension vs brevity thing, and a matter of personal style.