I dont get this Functions Calling Functions


#1


https://www.codecademy.com/courses/python-beginner-c7VZg/1/4?curriculum_id=4f89dab3d788890003000096#

can someone explain more details about function calling other function. i dont get it and i dont know the answer. this is shameful lol :cry:



#2

Functions calling other functions is like normally calling functions really. Just make sure the function being called is defined above the function that is calling it. You just call it the same way you'd call it outside a function.

def one_good_turn(n):
    return n + 1
    
def deserves_another(n):
    return one_good_turn(n) + 2

As you see, one_good_turn() is defined above deserves_another(), and both take the argument n. Then, as like you would outside of another function, one_good_turn() is called, just within the deserves_another() function, so it can be added to 2, making the result of deserves_another() equal to the result of one_good_turn() + 2.


#3

thanks for the explanation. still need a time to grasp this though


#4

If you run into anything else feel free to post.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.