A messy Downloads folder is the perfect first automation. You'll take a list of filenames, figure out where each one belongs based on its extension, and print a tidy summary — the same logic a real file organizer uses, minus the risk of moving real files.
Your tasks
Given these starting values:
filenames = ["report.pdf", "photo.jpg", "notes.txt", "budget.pdf", "logo.png"]
folder_for = {"pdf": "documents", "txt": "documents", "jpg": "images", "png": "images"}
counts = {}
1. Loop over each name in filenames.
2. Get the extension by splitting the name on "." and taking the last piece (e.g. name.split(".")[-1]).
3. Look up the destination folder in folder_for; use "other" if the extension isn't found (tip: folder_for.get(ext, "other")). Print "{name} -> {folder}/".
4. Track how many files go to each folder in counts. After the loop, print "{folder}: {count} files" for each folder in alphabetical order (use sorted(counts)).
Expected output
report.pdf -> documents/
photo.jpg -> images/
notes.txt -> documents/
budget.pdf -> documents/
logo.png -> images/
documents: 3 files
images: 2 files
Constraints
- Use
.split(".") to get the extension
- Use
.get() with a default for the lookup
- Use
sorted() for the summary order
- No external libraries; do not touch the real filesystem