Welcome to Westonci.ca, your one-stop destination for finding answers to all your questions. Join our expert community now! Join our platform to connect with experts ready to provide precise answers to your questions in different areas. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
Sagot :
Answer:
Following are the code to this question:
def combine_guest(guest1, guest2):#defining a method combine_guest that accepts two dictionary
guest2.update (guest1)#use dictionary guest2 that use update method to update guest2 dictionary
return guest2#return guest2 dictionary values
Rory_guest= { "Ada":2, "Ben":3, "Dav":1, "Jo":3, "Charry":2, "Terry":1, "bob":4}#defining a dictionary and add value
Taylor_guest = { "Dav":4, "Nan":1, "bobert":2, "Ada":1, "Samantha":3, "Chr":5}#defining a dictionary and add value
print(combine_guest(Rory_guest,Taylor_guest))#calling the combine_guest method
Output:
{'Nan': 1, 'Samantha': 3, 'Ada': 2, 'bob': 4, 'Terry': 1, 'Jo': 3, 'Ben': 3, 'Dav': 1, 'Charry': 2, 'bobert': 2, 'Chr': 5}
Explanation:
In the code a method, "combine_guest" is defined, that accepts two dictionaries "guest1, guest2" inside the method, in which the "guest2" dictionary uses the update method to combine the value of the guest1 dictionary and use a return keyword to return guest2 values.
In the next step, two dictionaries are declared, that holds some values and use a print method to call the "combine_guest" method and prints its return values.
Visit us again for up-to-date and reliable answers. We're always ready to assist you with your informational needs. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.