“ZIP List to Dictionary Python” Ответ

ZIP List to Dictionary Python

keys = ['a', 'b', 'c']
values = [1, 2, 3]
dictionary = dict(zip(keys, values))
print(dictionary) 
# {'a': 1, 'b': 2, 'c': 3}

Python Zip перечисляет в словаре

# app.py

stocks = ['reliance', 'infosys', 'tcs']
prices = [2175, 1127, 2750]
dictionary = dict(zip(stocks, prices))
print(dictionary)
Super Salamander

Словарь конвертирует 2 списка в словарь, используйте Zip ()

# convert 2 lists into a dictionary, use zip()

aa = [1, 2, 3]
bb = ["a", "b", "c"]

print(dict(zip(aa, bb)))
# {1: 'a', 2: 'b', 3: 'c'}
Sore Sloth

Ответы похожие на “ZIP List to Dictionary Python”

Вопросы похожие на “ZIP List to Dictionary Python”

Больше похожих ответов на “ZIP List to Dictionary Python” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования