Write a Python program to get the frequency of the elements in a given list of lists
- برمجة
- برمجة بايثون
- 2021-04-16
- salsabeelalhams99111801528
الأجوبة
def count_elements_lists(nums):
nums = [item for sublist in nums for item in sublist]
dic_data = {}
for num in nums:
if num in dic_data.keys():
dic_data[num] += 1
else:
key = num
value = 1
dic_data[key] = value
return dic_data
nums = [
[1,2,3,2],
[4,5,6,2],
[7,8,9,5],
]
print("Original list of lists:")
print(nums)
print("\nFrequency of the elements in the said list of lists:")
print(count_elements_lists(nums))أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال