Q37Comprehension3 Marks7 Aug 2022
Passage
Consider the following csv file named capitals.csv. Note that the file has exactly 11 lines and the entire file is given below for your reference.
```
continent,country,capital
asia,india,delhi
europe,uk,london
asia,china,beijing
europe,portugal,lisbon
africa,egypt,cairo
asia,pakistan,islamabad
europe,germany,berlin
europe,france,paris
africa,kenya,nairobi
europe,spain,madrid
```
Execute the following code given below and answer the subquestions:
```
fh = open('capitals.csv', 'r')
fh.readline() # read the header
d = dict()
for line in fh:
line = line.strip().split(',')
continent, country, capital = line
if continent not in d:
d[continent] = dict()
d[continent][country] = capital
fh.close()
```
What is the output of the following snippet of code?
```
P = dict()
for country in d['europe']:
capital = d['europe'][country]
P[capital] = country
print(P)
```