Skip to content
Advertisement

Is there a better way to find specific value in a python dictionary like in list?

I have been practicing on iterating through dictionary and list in Python.

The source file is a csv document containing Country and Capital. It seems I had to go through 2 for loops for country_dict in order to produce the same print result for country_list and capital_list.

Is there a better way to do this in Python dictionary?

The code:

JavaScript

The output:

JavaScript

The CSV file content:

JavaScript

Advertisement

Answer

I am not sure if I get your point; Please check out the code.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement