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 21:00
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
question
Computers and Technology, 23.06.2019 00:00
How do we use the sumif formula (when dealing with different formats) ?
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
What is the process in which the software development team compiles information to determine the final product
Answers: 1
question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
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, 08.07.2019 09:30
question
Mathematics, 08.07.2019 09:30
question
Mathematics, 08.07.2019 09:30
Questions on the website: 13722362