Lista a String Python
list1 = ['1', '2', '3']
str1 = ''.join(list1)
Amused Antelope
list1 = ['1', '2', '3']
str1 = ''.join(list1)
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'}
keys = ('name', 'age', 'food')
values = ('Monty', 42, 'spam')
out = dict(zip(keys, values))
#This is to convert two lists into a dictionary in Python
#given ListA is key
#given ListB is value
listA = ['itemA','itemB']
listB = ['priceA','priceB']
dict(zip(listA, listB))
# Returns
{'itemA': 'priceA',
'itemB': 'priceB'
}
single_dict = dict((k,v) for k,v in [item for subtup in list_of_dict for item in subtup])