Forums

FUNCTION CALLS

Hi there

I would like to know why the following program works with functions called before they are defined.

def main():
    name = get_name()
    house =get_house()
    print(f"{name} from {house}")

def get_name():
        return input("name")

def get_house():
    return input("house")

Thank you for any help.

Your code is not being executed (you don't have any function calls). If you'd put call to main() under the main definition, you would get NameError; if you'd put the call at the end of the file, it will work fine.