BugLab

Read the code.
Find the bug.

Short, broken Python functions. Predict what they do, point at the bug, explain it, then fix it. Runs in your browser. No account.

The kind of thing you will find
def sum_list(numbers):
total = 0
for i in range(len(numbers) - 1):
total += numbers[i]
return total

sum_list([1, 2, 3]) returns 3. Why?

Solved0 of 20 solved · 0 pts
001Off By Oneloopsindexingnot found yetP L E Feasyopen002The Silent Returnfunctionsscopenot found yetP L E Feasyopen003Is It Prime?mathloopsnot found yetP L E Fmediumopen004The Haunted Listfunctionsdefaultsnot found yetP L E Fmediumopen005One Too Manymathloopsnot found yetP L E Fmediumopen006Closure Trapclosuresfunctionsnot found yetP L E Fhardopen007Vanishing Elementslistsiterationnot found yetP L E Fhardopen008Exhaustedgeneratorsiteratorsnot found yetP L E Fhardopen009Identity Crisiscomparisonidentitynot found yetP L E Fmediumopen010Almost Equalfloatsprecisionnot found yetP L E Fmediumopen011Sorted by Nothinglistssortingnot found yetP L E Feasyopen012The Lost Returnrecursioncontrol-flownot found yetP L E Fmediumopen013Zero Productloopsaccumulatornot found yetP L E Feasyopen014Wrong by Designoperatorsprecedencenot found yetP L E Feasyopen015Read-Onlystringsimmutabilitynot found yetP L E Feasyopen016Missing KeydictsKeyErrornot found yetP L E Fmediumopen017The Shared Rowlistsreferencesnot found yetP L E Fhardopen018Wrong Rankloopsenumeratenot found yetP L E Feasyopen019Misleading Truthbooleanstruthinessnot found yetP L E Feasyopen020The Ignored Starsfunctionsargsnot found yetP L E Fmediumopen