TryBugHunt
pythonType errorEasy

Class report crashes after adding up the scores

BugFind the bug and fix the code

What it should do

class_report(scores) returns [total of all scores, how many scores are 50 or more]. Example: class_report([40, 60, 80]) → [180, 2].

What happens instead

class_report([40, 60, 80]) crashes: TypeError: 'int' object is not callable.

def class_report(scores):
    sum = 0
    for s in scores:
        sum += s
    passed = sum(1 for s in scores if s >= 50)
    return [sum, passed]

Test a custom input to verify an edge case (e.g. empty lists, negative numbers, duplicates).

⏱️0:00
Hints
🏆 0 hints = Flawless Solve
Think & Test Cooldown
2:00 remaining

Take a moment to read the bug symptom and trace the code with Run & Check before unlocking Hint 1.

Hint 2
Unlocks after Hint 1
Hint 3
Unlocks after Hint 2

This bug belongs to the type errors pattern

Strings that look like numbers, totals that refuse to add, comparisons between str and int.

What you'll practise

An easy Python debugging exercise about type errors: strings that look like numbers, totals that refuse to add, comparisons between str and int.

The checks your fix must pass

Signs of this kind of bug

Spoiler: why this bug happens(try it first; the hints get warmer one at a time)

What went wrong: the variable is called sum, so it hides Python's sum() function. sum(...) then tries to call the number 180.

The fix: rename the variable to total in all three places.

Remember: don't name variables sum, list, str, max, min or input.

The pattern behind it: type errors.

More type errors to practise

Seen this error in your own code?

Embed this challenge on your site

Paste this into any web page or blog post. Visitors fix the bug right there, in their browser.

<iframe src="https://trybughunt.com/embed/aa06aa7c-bc8e-4052-bd25-6788b1b888a6" title="Debugging challenge: Class report crashes after adding up the scores" width="100%" height="580" loading="lazy" style="border:1px solid #d4d4d8;border-radius:12px;max-width:760px"></iframe>
<p style="font-size:14px">Debugging challenge from <a href="https://trybughunt.com/challenges/aa06aa7c-bc8e-4052-bd25-6788b1b888a6">TryBugHunt</a></p>