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 )# from  w w w . j  av  a 2  s .  c o m

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

print( D1 )

Result

Related Topic