Q:

Write a Python program to get the frequency of the elements in a given list of lists. Use collections module

0

Write a Python program to get the frequency of the elements in a given list of lists. Use collections module

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

from collections import Counter
from itertools import chain
nums = [
        [1,2,3,2],
        [4,5,6,2],
        [7,1,9,5],
       ]
    
print("Original list of lists:")
print(nums)
print("\nFrequency of the elements in the said list of lists:")
result = Counter(chain.from_iterable(nums))
print(result)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now