Not another LeetCode.
Most platforms ask: can you write it? Real work asks: why is this broken?
BugLab builds code-reading and debugging skills — one broken function at a time. Especially relevant as AI tools write more of the code we all maintain.
The function sum_list should return the sum of all elements in a list. Something is wrong — it seems to miss the last element. Find the bug and fix it. Don't use sum() built-in — you must iterate manually.
The function make_multipliers(n) should return a list of n functions, where the i-th function multiplies its argument by i. So make_multipliers(4)[2](5) should return 10 (2 × 5). But every single function in the list behaves identically — they all multiply by the same number. This is one of Python's most infamous gotchas. The code looks right. But it isn't.
The function get_median(numbers) should return the median value of a list of numbers. For odd-length lists, the median is the middle element; for even-length lists, it is the average of the two middle elements. The function crashes immediately on any input with a TypeError. Can you find the single-word fix that makes it work?
The function word_frequency(words) should take a list of words and return a dictionary mapping each word to how many times it appears. It crashes on the very first word every single time. The error happens on a line that looks perfectly logical. Why does Python refuse to increment something that doesn't exist yet?