Stop creating 100 separate variables (`score1`, `score2`...). Upgrade your toolkit with Lists and Matrices to handle massive datasets with a single line of code.
Lists are dynamic. You can add, remove, and insert items on the fly. Interact with the "Magic Box" below to see how methods like .append() and .pop() change the data structure.
Adds to the end.
Jumps the queue.
Removes & returns last item.
Deletes first occurrence.
Unlock the power to cut, copy, and reverse data with the syntax:
[start : stop : step]
Instantly flips the array backwards.
Takes every 2nd item (0, 2, 4...).
Result
Create new lists in a single line. It's cleaner, faster, and more "Pythonic". See how LC filters and transforms data instantly compared to traditional loops.
Displaying raw student scores.
Data isn't always linear. Use matrix[row][col] for grids, maps, and tables.
Click two cells to calculate Manhattan Distance.
Formula: |r1 - r2| + |c1 - c2|
Rotating a matrix 90° clockwise involves remapping indices.
new_c = N - 1 - old_r
Never use [[0]*N]*N. It links rows together!
Always use Nested List Comprehension.