Objective
Create a Python program that reads a CSV with a header and shows the people of a city using csv.DictReader.
Instructions
- Read an integer
n. - Read a header line
name,age,cityand thenndata rows. - Go through the rows with
csv.DictReader, passing it the list made of the header and the rows. Each row will be a dictionary with the keysname,ageandcity. - Read the city to look for.
- Show the name of each person who lives in that city, one per line and in the order of the file. If there are none, show
None.
4
name,age,city
ana,30,madrid
luis,25,lyon
eva,41,madrid
pepe,19,roma
madrid
ana
eva
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise