Question: Write a function named counter_dict that takes input a list. * returns a dictionary whose keys are the set of elements of the input

Write a function named counter_dict that takes input a list. * returns 

Write a function named counter_dict that takes input a list. * returns a dictionary whose keys are the set of elements of the input list and the values are number of occurences of that key in the input list. For example, if the input list is ['Paris', 'London', 'Moscow', 'London', 'Helsinki', 'London', 'Paris'] the counter_dict function should return {'Paris': 2, 'London': 3, 'Helsinki': 1, 'Moscow'; 1). Notes: Of course, ordering of the items in the dictionary is not important. [5]: my_travels = ['Paris', 'London', 'Moscow', 'London', 'Helsinki', 'London' -, 'Paris'] def counter_dict (input): # Do the job here pass #Call the function and see if it works counter_dict (my_travels)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the implementation of the counterdict function python ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!