“Liste des DICT, um Python zu diktieren” Code-Antworten

Listen Sie auf, um Python zu dikten

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'}
InsomaniaCl

Python -Liste zu dikten

keys = ('name', 'age', 'food')
values = ('Monty', 42, 'spam')
out = dict(zip(keys, values))
Kevin Yeung

Liste des DICT, um Python zu diktieren

single_dict = dict((k,v) for k,v in [item for subtup in list_of_dict for item in subtup])
Clever Caterpillar

Liste des DICT, um Python zu diktieren

single_dict = dict((k,v) for k,v in [item for subtup in list_of_dict for item in subtup])
Clever Caterpillar

Ähnliche Antworten wie “Liste des DICT, um Python zu diktieren”

Fragen ähnlich wie “Liste des DICT, um Python zu diktieren”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen