BugHunt

Common bug patterns in Python and JavaScript

Most bugs are not new. They are the same handful of shapes, over and over. Learn to recognise the shape and you find the next one in minutes instead of hours.

Off-by-one errors

The loop that runs one time too many, the slice that drops the last item, the index that starts in the wrong place.

IndexError: list index out of range

Infinite loops

The tab freezes, nothing prints, and the loop condition never becomes false.

while loop never ends

Null and undefined errors

Cannot read properties of undefined, NoneType has no attribute, NaN appearing from nowhere.

TypeError: Cannot read properties of undefined (reading 'x')

Type errors

Totals that concatenate, sorts that put 10 before 9, comparisons that refuse to run.

TypeError: unsupported operand type(s)

Scope and closure bugs

Every callback reports the last value, a counter never increments, UnboundLocalError on a variable you can see.

UnboundLocalError: cannot access local variable

Async and race conditions

A missing await, results in the wrong order, and updates that overwrite each other under load.

[object Promise] in output

Logic errors

The wrong operator, an inverted condition, a formula the right way round but backwards.

wrong output but no error

Mutation and copying bugs

Assignment does not copy, a shallow copy still shares its contents, and mutating methods return None.

editing copy changes original

Every pattern comes with free challenges you fix in the browser — browse all challenges. BugHunt runs your code in your own tab; there is nothing to install.