Skip to content
Home » Python program to count the frequency of a given list of numbers

Python program to count the frequency of a given list of numbers

Program to count the frequency of given numbers in python

lst=eval(input("Enter list:"))
length=len(lst)
element=int(input("Enter element:"))
count=0
for i in range(0,length):
    if element==lst[i]:
        count+=1
if count=0:
    print(element,"not found in the list")
else:
    print(element,"has frequency as",count,"in the given list")

Output

Enter list:[17,16,18,17,17,25,25,23,26]

Enter element:17

17 has frequency as 3 in the given list