** * This article is from Udemy "[Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style](https://www.udemy.com/course/python-beginner/" Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style ")" It is a class notebook for myself after taking the course of. It is open to the public with permission from the instructor Jun Sakai. ** **
week = ['Mon', 'Tue', 'Wed']
drink = ['coffee', 'milk', 'water']
d = {}
for x, y in zip(week, drink):
d[x] = y
print(d)
result
{'Mon': 'coffee', 'Tue': 'milk', 'Wed': 'water'}
week = ['Mon', 'Tue', 'Wed']
drink = ['coffee', 'milk', 'water']
d = {x: y for x, y in zip(week, drink)}
print(d)
result
{'Mon': 'coffee', 'Tue': 'milk', 'Wed': 'water'}
Recommended Posts