Skip to main content

Inventory Aggregator

Challenge on lesson: Checkpoint: Files + Modules

csv_text = "apple,fruit\ncarrot,veg\nbanana,fruit\nleek,veg\ncherry,fruit" is given. Write count_categories(text) that parses the CSV (comma-separated, one item per line) and returns a dict mapping each category (column 2) to how many items it has. Print the dict — one line.

Difficulty: beginner

Back to lesson: Checkpoint: Files + Modules