Bug Fix

The Vanishing List

The Vanishing List

Bug Report

A list of scores is sorted and assigned to a new variable. When trying to print the first (lowest) score, it crashes with 'TypeError: NoneType object is not subscriptable'.

List Methodssort vs sortedReturn Values
Fix the Bug: The Vanishing List

The list.sort() method sorts a list IN PLACE and always returns None — it's meant for side effects, not for producing a new value. Assigning its result to a variable gives you None instead of the sorted list. Use sorted() instead if you want a new sorted list returned.

EditorPython · JSX
PreviewUpdates on Run Tests
Loading preview…
Tests
Should use sorted() instead of .sort()
Should NOT rely on the return value of .sort()
Should return the sorted list