# Chapter12.py # Dictionary Entries # Sets of key: value pairds # key name can not duplicate # value can be a duplicate # the key name has to be a string 'key' # the value can be any type # Like lists, you should create an empty dictionary before adding entries # create an empty dictionary contacts = {} # { {f:v,l:v,a:v} , {f:v,l:v,a:v} } contact = {} # {f:v,l:v,a:v} firstName = 'Bob' # input() lastName = 'Smith' age = 45 # int # create a new contact entry contact = { 'firstName': firstName, 'lastName': lastName, 'age': age } # contact{} contacts.update(contact) print(f"Individual contact: {contact}") print("----") print(f"Set of contacts: {contacts}") ####### firstName = 'Jane' # input() lastName = 'Doe' age = 45 # int # create a new contact entry contact = { 'firstName': firstName, 'lastName': lastName, 'age': age } # contact{} contacts.update(contact) print(f"Individual contact: {contact}") print("----") print(f"Set of contacts: {contacts}") # read the individual keys # loop thru all the key and value for k,v in contact.items(): print(f"Key: {k}, Value: {v}") print(f"{k} -> {v}")