CSV Report Generator
Write a program that saves 3 products (name and price) to a CSV file, then reads it back using csv.DictReader and prints each product.
What the problem means: CSV is a common way to store simple tabular data as plain text — this exercises writing rows with csv.writer and reading them back by column name with csv.DictReader.
Approach: write a header row ("Name", "Price") plus 3 data rows with csv.writer, then reopen the file and use csv.DictReader to read each row as a dictionary.
Input: Three lines, each a product as name,price.
Output: Three lines: Name: <name>, Price: <price>, one per product, in the original order.
Pen,10 Notebook,50 Bag,500
Name: Pen, Price: 10 Name: Notebook, Price: 50 Name: Bag, Price: 500
- Each line is exactly `name,price` with no extra commas.
Hint 1
csv.writer(file).writerow([...]) writes one row (list of values) at a time — write the header row first.
Hint 2
Open the file for writing with newline="" to avoid extra blank lines.
Hint 3
csv.DictReader(file) lets you read each row back as a dictionary, keyed by the header names.
Write the header row ["Name", "Price"] followed by the 3 product rows using csv.writer, opening the file with newline="" as is standard practice. Reopen it and loop over csv.DictReader(file), which turns every row back into a dictionary keyed by the header — so row["Name"] and row["Price"] read naturally.