First-Class Function References
def shout(text):
print("built shout handler")
return text.upper() + "!"
def whisper(text):
print("built whisper handler")
return text.lower() + "..."
handlers = {"loud": shout, "quiet": whisper}
print("handlers ready")
result = handlers["loud"]("go")
print(result)
What does this print, in order?
Sign in to answer questions and track your progress
Sign In