Question: Python - How to convert a file into a dictionary? I have a text file Japan,Tokyo-Yokohama,37843000 Indonesia,Jakarta,30539000 South Korea,Seoul-Incheon,23480000 I wish to read this file

Python - How to convert a file into a dictionary?

I have a text file

Japan,Tokyo-Yokohama,37843000 Indonesia,Jakarta,30539000 South Korea,Seoul-Incheon,23480000

I wish to read this file to dictionary as follows (key => city, value => country and population), i.e. Tokyo-Yokohama: ['Japan', '37843000'] Jakarta: ['Indonesia', '30549000'] Seoul-Incheon: ['South Korea', '23480000']

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!