Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Creating dictionary from two lists using zip

names = ['Jan', 'Feb', 'Mar', 'Apr']
days =  [31, 28, 31, 30]

zipped = zip(names, days)
print(zipped)
print(list(zipped))

zipped = zip(names, days)
month = dict(zipped)
print(month)

Output:

{'Jan': 31, 'Feb': 28, 'Mar': 31, 'Apr': 30}