Q:

Write a Python program to get the frequency of the tuples in a given list

0

 Write a Python program to get the frequency of the tuples in a given list

All Answers

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

from collections import Counter
nums = [(['1', '4'], ['4', '1'], ['3', '4'], ['2', '7'], ['6', '8'], ['5','8'], ['6','8'], ['5','7'], ['2','7'])]
print("Original list of tuples:")
print(nums)
result = Counter(tuple(sorted(i)) for i in nums[0])
print("\nTuples","    ","frequency")
for key,val in result.items():
    print(key," ", val)

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