I’m told to
Write a method freq(a) that returns a dictionary that, for each unique
value x in a, maps x onto the number of occurrences of x in a.
This is my first time working with dictionaries and I tried reading up to see how I would attack this problem, but I’m not sure how to code it..
This is what I believe I have to do..
1. create a dictionary with two values. [x:y]
2. evaluate the list.
3.1 if the value in the list is not in the dictionary, make the value x:1
3.2 if the value in the list is in the dictionary, make the value y+1
4. return results
is this how you would do this problem?
how would I code step 3?
without using either
collections.Counterorcollections.defaultdict: