subject

#write a function called rabbit_hole. rabbit_hole should have#two parameters: a dictionary and a string. the string may be#a key to the dictionary. the value associated with that key,#in turn, may be another key to the dictionary.##keep looking up the keys until you reach a key that has no#associated value. then, return that key.##for example, imagine if you had the following dictionary.#this one is sorted to make this example easier to follow: ## d = {"bat": "pig", "pig": "cat", "cat": "dog", "dog": "ant",# "cow": "bee", "bee": "elk", "elk": "fly", "ewe": "cod",# "cod": "hen", "hog": "fox", "fox": "jay", "jay": "doe",# "rat": "ram", "ram": "rat"}##if we called rabbit_hole(d, "bat"), then our code ## - look up "bat", and find "pig"# - look up "pig", and find "cat"# - look up "cat", and find "dog"# - look up "dog", and find "ant"# - look up "ant", and find no associated value, and so it would# return "ant".##other possible results are: ## rabbit_hole(d, "bat") -> "fly"# rabbit_hole(d, "ewe") -> "hen"# rabbit_hole(d, "jay") -> "doe"# rabbit_hole(d, "yak") -> "yak"##notice that if the initial string passed in is not a key in#the dictionary, that string should be returned as the result as#well.##note, however, that it is possible to get into a loop. in the#dictionary above, rabbit_hole(d, "rat") would infinitely go#around between "rat" and "ram". you should prevent this: if a#key is ever accessed more than once (meaning a loop has been#reached), return the boolean false.##hint: if you try to access a value from a dictionary that does#not exist, a keyerror will be raised

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
Awell-diversified portfolio needs about 20-25 stocks from different categories.
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
question
Computers and Technology, 24.06.2019 01:00
What shows the web address of the page that is currently displayed in the workspace? status window toolbar location bar internet box
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Could you find out how im still getting an 83 percent on this in edhesive a = input("enter an animal: ") s = input ("enter a sound: ") e = "e-i-e-i-o" print ("old macdonald had a farm, " + e) print ("and on his farm he had a " + a + "," + e) print ("with a " + s + "-" + s + " here and a " + s + "-" + s + " there") print ("here a " + s+ " there a " + s) print ("everywhere a " + s + "-" + s ) print ("old macdonald had a farm, " + e)
Answers: 2
You know the right answer?
#write a function called rabbit_hole. rabbit_hole should have#two parameters: a dictionary and a st...
Questions
question
Mathematics, 01.07.2019 15:10
Questions on the website: 13722360