a=["Seoul", "Seoul", "Gyeonggi", "Gyeonggi", "Incheon", "Incheon"]
dic={0: 'Seoul', 1: 'Seoul', 2: 'Gyeonggi', 3: 'Gyeonggi', 4: 'Incheon', 5: 'Incheon'}
How do I change from a to dic?
list dictionary
In [2]: a=[Seoul, Seoul, Gyeonggi, Gyeonggi, Incheon, Incheon]
In [3]: dict(zip(range(len(a)), a))
Out[3]: {0: 'Seoul', 1: 'Seoul', 2: 'Gyeonggi', 3: 'Gyeonggi', 4: 'Incheon', 5: 'Incheon'}
© 2024 OneMinuteCode. All rights reserved.