Objective
Create a Python program that reads CSV lines whose fields may contain commas, thanks to the quotes.
Instructions
- Read an integer
nand thennlines with the formatname,"city, country",age. The second field is in quotes because it contains a comma. - Process the lines with
csv.reader, which knows how to interpret the quotes. - For each line show
name lives in city, country. - If you had used
split(","), the field would have been cut in two: that is the advantage of thecsvmodule.
2
Ana,"Madrid, España",30
Luis,"Lyon, Francia",25
Ana lives in Madrid, España
Luis lives in Lyon, Francia
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise