0

Program to find frequencies of all elements in a list...?

List manipulation

14th Dec 2019, 4:28 AM
Yashvi Saxena
3 odpowiedzi
+ 1
A simple way to get this, is by iterating over a list of elements with a for loop. To store the results you can use a dictionary. In this dict the elements will get the keys. If element is not in dict (key), a new key must be created and a value of 1 must be set as value. If key already exists the counter (value) must be incremented by 1. After the iteration over list, the dict contains key:value pairs.
14th Dec 2019, 8:47 AM
Lothar
Lothar - avatar
14th Dec 2019, 6:12 AM
Louis
Louis - avatar