What is the best way to exit a function (which has no return value) in python before the function ends (e.g. a check fails)?
you can use the return
statement without any parameter to exit a function
def foo(element): do something if check is true: do more (because check was succesful) else: return do much much more...
or raise an exception if you want to be informed of the problem
def foo(element): do something if check is true: do more (because check was succesful) else: raise Exception("cause of the problem") do much much more...