Write a function, common(list1, list2), that returns a dictionary. Each key in the dictionary corresponds to an element

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a function, common(list1, list2), that returns a dictionary. Each key in the dictionary corresponds to an element

Post by answerhappygod »

Write A Function Common List1 List2 That Returns A Dictionary Each Key In The Dictionary Corresponds To An Element 1
Write A Function Common List1 List2 That Returns A Dictionary Each Key In The Dictionary Corresponds To An Element 1 (37.63 KiB) Viewed 46 times
Write a function, common(list1, list2), that returns a dictionary. Each key in the dictionary corresponds to an element in both of the lists. The value for each key is the number of times that element appears across both lists. See the testing cell below for an example. HINT: There are multiple ways to solve this, but you may find the simplest involves building at least two intermediate dictionaries and multiple loops. Use this cell to test whether you have implemented the function correctly. [] assert common (["a", "b", "a", "d", "f", "a"], ["a", "b", "d", "d", "e"]) == { "a": 4, "b": 2, "d": 3 }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply