R

Ram Sharma • 3.40K Points
Extraordinary

Q. What does this code print?

Code:
def outer():
def inner():
return 'Hello from inner'
return inner()

print(outer())
  • (A) Hello from inner
  • (B) inner
  • (C) outer
  • (D) Error
  • Correct Answer - Option(A)
  • Views: 8
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma
The outer function defines and calls `inner`, which returns a string. So the final output is 'Hello from inner'.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.