Write a python program to find the Frequency of all the elements of a list and also to print the list of Unique and Duplicate elements of given list

Tech Programmer
0

Write a python program to find the frequency of all the elements of a list and also to print the list of unique and duplicate elements of the given list.


CODE FOR THE ABOVE  PYTHON  PROGRAM :



lst = eval(input(" ENTER LIST : "))
length = len(lst)
uniq = []
dupl = []
count = i = 0
while i < length:
    element = lst[i]
    count = 1
    if element not in uniq and element not in dupl:
        i+=1
        for j in range(ilength):
            if element==lst[j]:
                count+=1
        else:
            print("Element",element,"Frequency",count)
            if count==1:
                uniq.append(element)
            else:
                dupl.append(element)
    else:
        i+=1

print("ORIGINAL LIST : ",lst)
print("UNIQUE ELEMENTS LIST : ",uniq)
print("DUPLICATE ELEMENTS LIST : ",dupl)


WRITTEN CODE FOR THE ABOVE PROGRAM :


lst = eval(input(" ENTER LIST : "))

length = len(lst)

uniq = []

dupl = []

count = i = 0

while i < length:

    element = lst[i]

    count = 1

    if element not in uniq and element not in dupl:

        i+=1

        for j in range(i, length):

            if element==lst[j]:

                count+=1

        else:

            print("Element",element,"Frequency",count)

            if count==1:

                uniq.append(element)

            else:

                dupl.append(element)

    else:

        i+=1


print("ORIGINAL LIST : ",lst)

print("UNIQUE ELEMENTS LIST : ",uniq)

print("DUPLICATE ELEMENTS LIST : ",dupl)


OUTPUT :



Post a Comment

0Comments
Post a Comment (0)

Featured Highlighted Categories

You'll discover all of the most up-to-date bring innovative here.

Python List theory with List Programs
Get complete python lists theory and list basic and insane programs for your practice.
CBSE SAMPLE PAPERS
Get CBSE sample and question papers of last 7 years with answers to get best practice for your Board Exams
Python String theory and String Programs
Python strings complete theory with illustrations and practice programs for free