Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(Python) Anyone can tell me what is wrong with my first function? and tell me how to write the second function? Thanks! 1. Define a
(Python) Anyone can tell me what is wrong with my first function? and tell me how to write the second function? Thanks!
1. Define a function reverse_lookup that takes in a dictionary and a value. Your function will find and return a key associated with with the inputted value if one exists. If the value is not in the dictionary, return None. Hint: Try iterating through the dictionary using a for loop and comparing each key-value pair to the value you're looking for. Remember, there are ways to see the key AND value of a dictionary when using a for loop. 2. Define a function generate_kv_strings that takes in a dictionary as the argument. Your function will iterate through the dictionary to create then return a list of strings representing each key-value pair from the dictionary, where each string will be in the format 'key value (where key and value are the respective keys and values from the given dictionary). Hint: A list comprehension can make this function much shorter, but you are not required to use one. Hint: Remember that you need to convert each key and value into a str before concatenating them, in case they are of a different type
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started