Question: python Problem 2 Write code which, given a list 1. produces a dictionary D where: The keys of D are the unique elements of L
Problem 2 Write code which, given a list 1. produces a dictionary D where: The keys of D are the unique elements of L (i.e. each element of L appears only once). The value D[i] is the number of times that i appears in list L. Demonstrate that your code works for lists of strings, lists of integers, and lists containing both strings and integers. (it's fine to copy and paste your code for this, although if you happen to know how to define functions then you might find that more efficient). For example: L = ["a", "a", "b", "c"] # your code here # D # output {"a": 2, "b" : 1, "C" : 1}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
