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
Get step-by-step solutions from verified subject matter experts
