Python program to find frequencies of all the elements of a list. Also print the duplicate elements of the list?
Answers
Answered by
7
n = int(input("Enter the number of elements you'd like to add: "))
print()
l = list()
for i in range(n):
x = eval(input("Enter the element: "))
l.append(x)
print()
print()
print(l, "is your given list.")
print()
for i in l:
print(i, "occurs", l.count(i), "times.")
print()
dl = list()
for i in l:
if l.count(i) > 1:
if i not in dl:
dl.append(i)
print(dl, "is the list of duplicate elements.")
Similar questions