Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Returning Functions From Functions

This lesson covers how to return functions from functions. The code example in the lesson uses a function called parent() that contains two inner functions that return a string of text:

def parent(num):
    def first_child():
        return "Hi, I am Emma"

    def second_child():
        return "Call me Liam"

    if num == 1:
        return first_child
    else:
        return second_child

You’ll see how to access these inner functions and assign them to variables.

Comments & Discussion

Anonymous on March 20, 2019

Nice and clear explainations though the pace for me is a little faster than I would like.

Rynaldo I Bama on March 24, 2019

It explains the concepts clearly and concisely.

Become a Member to join the conversation.