Write a python program to find the frequency of a number in a list.

 

Answer:

Code:

list1=[] 

count= 0

 

n=int(input( "Enter the number of elements in the list: " ))

 

for i in range(n):

    list1.append(int(input( "Enter element: " )))

 

search=int(input( "Enter the number to check frequency of: " ))

 

for i in range(n):

    if(list1[i]==search):

        count=count+ 1

 

print("Frequency of ",search," is: ",count)

 

Write a python program to find the frequency of a number in a list. - Long Answer Type Questions (5 Marks each)

Remove Ads
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.

Many students prefer Teachoo Black for a smooth, ad-free learning experience.