Answer:
The program in Python is as follows:
phonedirs = {'Maegan': 1 , 'McCulloch': 2, 'Cindy': 3}
for i in range(2):
name = input("Name: ")
phonenum = int(input("Phone: "))
phonedirs [name] = phonenum
print(phonedirs)
Step-by-step explanation:
Given
The instruction in the question is incomplete.
See attachment for complete question
Required
Write a code that carries out the 4 instructions in the attachment
See answer section for solution.
The explanation is as follows:
(1) This initializes the phone book
phonedirs = {'Maegan': 1 , 'McCulloch': 2, 'Cindy': 3}
The following is repeated for the two friends
for i in range(2):
(2) This gets the name of each friend
name = input("Name: ")
(2) This gets the phone number of each friend
phonenum = int(input("Phone: "))
(3) This updates the phone book with the inputs from the user
phonedirs[name] = phonenum
(4) This displays the updated phone book
print(phonedirs)