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)

 

Question 3 Long Answer.jpg

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.