Answers for "python convert dict in list to list"

11

list to dict python

my_list = ['Nagendra','Babu','Nitesh','Sathya']
my_dict = dict() 
for index,value in enumerate(my_list):
  my_dict[index] = value
print(my_dict)
#OUTPUT
{0: 'Nagendra', 1: 'Babu', 2: 'Nitesh', 3: 'Sathya'}
Posted by: Guest on June-16-2020
0

python convert string to list of dictionaries

import json

with open('.listOfDicts.txt', 'r') as file:
    dataList = json.loads(file.read().replace('n', ''))

for dictItem in dataList:
    for key , val in dictItem.items():
        print( key , val )
Posted by: Guest on May-05-2020

Code answers related to "python convert dict in list to list"

Python Answers by Framework

Browse Popular Code Answers by Language