Skip to content
Advertisement

Tag: return

Python3 exec, why returns None?

When the code below this text, and returns the result None why? Result: Module code exx.py: Answer The problem of course is not only that print returns None, it is that exec returns None, always. If you’d need the return value, you’d use eval: after which you’d notice that print still returns None…

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)? [duplicate]

This question already has answers here: return, return None, and no return at all? (5 answers) Closed 4 months ago. Let’s assume an iteration in which we call a function without a return value. The way I think my program should behave is explained in this pseudocode: If I implement this in python, it bothers me, that the function returns

Advertisement