Skip to content
C

CSV Report Generator

Mediumpython

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.

Input (stdin)

Output

Run your code to see output here...