Back to Lesson
Custom Sort Logic
Use sorted() with a functional key to manipulate lists intelligently.
Instructions
- You have a list of strings representing file sizes:
files = ["10MB", "2MB", "150MB", "45MB"] - Create a functionthat returns
strip_mb(s).int(s.replace("MB", "")) - Useon the list with
sorted(), and print the resulting list.key=strip_mb
main.py
main.py
Ctrl + Enter