Junior — Middle
Is it possible in Python to write a function that does not explicitly return any values?
sobes.tech AI
Answer from AI
Yes, in Python, you can write a function that explicitly does not return any values. If a function lacks a return statement or uses it without a value, the function returns a special value None.
Example:
def foo():
print("Hello")
result = foo() # Will print Hello
print(result) # Will print None
Thus, the function does not explicitly return any values, but implicitly returns None.