Answered step by step
Verified Expert Solution
Link Copied!

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!

image text in transcribed

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

Students also viewed these Databases questions

Question

How does mindfulness fit into Buddhist philosophy?

Answered: 1 week ago