Reputation: 15732
This does print "None", I want it to print "True", I do not want to alter the last line of the code block.
def outer():
def inner():
return True
print(outer())
Upvotes: 0
Views: 1461
Reputation: 251428
outer
only defines a function, it doesn't call it. If you want outer
to return the result of inner
, you need to do that:
def outer():
def inner():
return True
return inner()
There is no way to make outer
return True
without altering it. (Note that you don't have to modify inner
.)
Upvotes: 4