Page 1 of 1

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

Posted: Fri Jul 01, 2022 5:53 am
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 48 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 }