5/19 Functions Calling Functions Help

Continuing the discussion from 17/19 Syntax Error:

Hi @caeleb, could you please post all your code using the following trick: Click here to learn how to post code into the forum.

Also, it would help if you could describe your problem and any error message you are getting when you try to run your code.

Thanks! :smile:

1 Like

def one_good_turn(n):
return n + 1

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

can someone tell me what is wrong here

Hi @pyplayer61299 and @systemmaster53319,

Click here to learn the trick for posting code into the forum.

Your code seems ok but since I cannot see your indentation, maybe the problem lies into indentation itself.

Here’s how it should look when properly indented:

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

Indentation is vital since Python use whitespace to group statements and create code blocks that are easy to read. More info here

Hope this helped! :smile:

1 Like

There’s no point to give him/her the right answer, because he/she will never learn what was right, and where the mistake was made. Consider actually helping your fellow learners by pointing out their mistakes

3 Likes

The return of one_good_turn is n + 1
The return of deserves_another is n + 2

You need to change it so that the return of deserves_another is one_good_turn(n) + 2 for it to always add 2 to the first function

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