Python - Dictionary construction with zip

Introduction

You can create a dictionary by coding a dictionary literal, or by assigning to keys over time:

Demo

D1 = {'test':1, 'eggs':3, 'toast':5} 
print( D1 )# ww  w . ja  va 2  s  . c  om

D1 = {} 
D1['test']  = 1 
D1['eggs']  = 3 
D1['toast'] = 5 

print( D1 )

Result

Related Topic