Excel Report from a List
Create an Excel file with product data using openpyxl, then read it back and print every row.
Approach: build a workbook, append a header row plus one row per product, save it, then reload it and print each row's values.
Input: First line: the number of products n. Next n lines: name,price.
Output: One line per row (including the header): the row's values as a tuple.
2 Pen,10 Notebook,50
('Name', 'Price')
('Pen', 10)
('Notebook', 50)- 1 <= n <= 100
Hint 1
wb = Workbook(); sheet = wb.active gives you a fresh worksheet to write into.
Hint 2
sheet.append([...]) adds one new row at a time — append the header first, then one row per product.
Hint 3
Don't forget wb.save("products.xlsx") — without it, nothing is written to disk.
Hint 4
load_workbook("products.xlsx").active.iter_rows(values_only=True) reads every row back as a plain tuple of values.
sheet.append([...]) adds the header row and then one row per product in order; wb.save(...) is what actually writes the file to disk. Reloading it with loadworkbook() and looping over sheet.iterrows(values_only=True) reads every row back as a plain tuple — whole-number prices come back as plain integers (not 10.0), since Excel doesn't distinguish a whole-number float from an integer internally.