len / sort / sort(reverse=True) / sorted
It’s Friday night in 1999. You’re wearing your blue polo and name tag, the smell of popcorn and plastic VHS cases fills the air, and a line of impatient customers wraps around the counter.
Welcome to RetroRewind Video, the last great movie rental store standing at Arcadia Mall. Your terminal is ancient, your shift is long, and your task is simple:
organize the movie database before the store opens!
Each of these list methods will help you clean up, count, and rearrange your titles just like the real Blockbuster computers once did.
Before you can organize anything, you have to know how many tapes are actually out there.
len() tells you how many items are in your list — like counting the number of DVDs on a shelf, or checking how many copies of The Matrix haven’t been returned yet.
len() returns a number (not a string).
Perfect for checking inventory totals or empty shelves!
Corporate memo just dropped: all titles must be sorted alphabetically!
The .sort() method is your secret weapon — it permanently rearranges your list, putting Apollo 13 before Titanic, just like the alphabetical sections on old rental shelves.
Use .sort(reverse=True) if you want to flip it Z–A, like those cool “Staff Picks” shelves in reverse order.
Ever wanted to see what your movie shelf would look like alphabetized, without actually moving the tapes yet?
sorted() lets you temporarily sort a list
it doesn’t change the original order.
Think of it like viewing the “Coming Soon” list before the tapes actually arrive.
sorted() makes a copy — the original stays untouched.
Use it when you just want a quick look before “reshelving.”
Sometimes management wants the shelf reversed — latest releases in the front, classics in the back.
The .reverse() method flips your entire list backward, without sorting alphabetically.
It’s like physically flipping every VHS spine in the opposite direction.
.reverse() does not sort — it just flips whatever order already exists.
This change is permanent, like rewinding the wrong tape before closing time.
If you just use .sort(), Python looks at the first thing in each list item.
In this case, it sorts alphabetically by the movie title.
Python only looked at the first item (m[0], the title) in each list.
It completely ignored the year — because it didn’t know you wanted that!
Now, let’s tell Python exactly what to look at: the year.
movies is your whole list — like your entire shelf of tapes.
When Python calls .sort(), it goes through your list one movie at a time.
Each individual movie (like ["The Matrix", 1999]) is temporarily stored in the variable name you write in your lambda — here, that’s movie.