Question: Python : must work for all cases not just test cases Function name: pair_rivals Parameters: A dictionary of one character as the key paired to

Python : must work for all cases not just test cases  Python : must work for all cases not just test cases

Function name: pair_rivals Parameters: A dictionary of one character as the key paired to one character as his/her rival. The other dictionary will also contain characters as keys and their rival as the values. Assume that valid arguments will always be passed in. Returns: A dictionary of tuple values paired to a boolean (either True or False) Description: As a movie/TV show fanatic you suddenly have the impulse to write a function that pairs rivals with each other. In this function you will take in two dictionary arguments, and return a new dictionary. Both parameters will have one string keys paired to one string values. Each key will represent a certain character and the value will be the rival of that character. If one character's rival in the first dictionary is that rival's rival in any of the dictionaries, add a tuple of both names as a key (first, second) in a new dictionary, paired to True as its value. In other words, only add it into the new dictionary if "character": "rival" in one is found as "rival":"character" somewhere. Add in the order of how it appears the first time. Note/Hint You may use TrylExcept, and you may use list) casting for this function Test cases one ("Naruto": "Sasuke", "Aang": "Zuko", "Ash": "Gary" >>two("Zuko": Aang", "Batman" "Joker") rivals1 pair_rivals(one, two) > print (rivals1) (C'Aang, 'Zuko): True) one ("Rick": "Evil Morty", "Spiderman": "Venom" "Dora": "Swiper") >to ("Evil Morty": "Morty", "Swiper": "Dora") >rivals2 pair_rivals(one, two) print (rivals2) 'Dora, Swiper): True)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!