Explore Westonci.ca, the leading Q&A site where experts provide accurate and helpful answers to all your questions. Join our platform to connect with experts ready to provide accurate answers to your questions in various fields. Get immediate and reliable solutions to your questions from a community of experienced professionals on our 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.
We hope this was helpful. Please come back whenever you need more information or answers to your queries. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.