Editor

Fix the Broken Function

Intermediate · Fix the bug · from Python Functions: Define, Call, and Return Values

From the lesson: Python Functions: Define, Call, and Return Values

Imagine you have a favorite recipe for pancakes. Every Sunday morning, you follow the same steps: mix flour, crack eggs, pour batter, flip. You don't reinvent the recipe each time - you just follow the one you already know.

Read the lesson

This function is supposed to return the larger of two numbers, but running it prints numbers and then None instead. Fix it so bigger(3, 7) returns 7 and bigger(10, 5) returns 10.

def bigger(a, b):
if a > b:
print(a)
print(b)
print(bigger(3, 7))
print(bigger(10, 5))

What Check runs

Your code runs first, then each of these lines. The output must match exactly.

RunsExpected output
print(bigger(3, 7))7
print(bigger(10, 5))10
print(bigger(4, 4))4

More Function exercises

All Python exercises · 50 practice problems · Functions quiz