Objective
Create a Python program that generates a CSV with csv.writer, letting the module take care of the quotes.
Instructions
- Read an integer
nand then, for each person, their name on one line and their age on the next. - Create a
csv.writerover anio.StringIO(), withlineterminator="\n". - Write the header
name,agefirst and then one row per person. - Show the generated content with
print(output.getvalue(), end=""). - If a name contains a comma, for example
Pérez, Ana, the module will automatically write it in quotes.
2
Ana
30
Luis
25
name,age
Ana,30
Luis,25
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise