Created
March 23, 2021 23:12
-
-
Save AnisahTiaraPratiwi/7494cf6392a824abb10d4582ddef207a to your computer and use it in GitHub Desktop.
Taylor and Rory are hosting a party. They sent out invitations, and each one collected responses into dictionaries, with names of their friends and how many guests each friend is bringing. Each dictionary is a partial list, but Rory's list has more current information about the number of guests. Fill in the blanks to combine both dictionaries in…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combine_guests(guests1, guests2): | |
# Combine both dictionaries into one, with each key listed | |
# only once, and the value from guests1 taking precedence | |
guests2.update (guests1) | |
return guests2 | |
Rorys_guests = { "Adam":2, "Brenda":3, "David":1, "Jose":3, "Charlotte":2, "Terry":1, "Robert":4} | |
Taylors_guests = { "David":4, "Nancy":1, "Robert":2, "Adam":1, "Samantha":3, "Chris":5} | |
print(combine_guests(Rorys_guests, Taylors_guests)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output is Here:
{'David': 1, 'Nancy': 1, 'Robert': 4, 'Adam': 2, 'Samantha': 3, 'Chris': 5, 'Brenda': 3, 'Jose': 3, 'Charlotte': 2, 'Terry': 1}