Computer Science, asked by BrainlySecurityIndia, 7 hours ago

Write a python program to count the frequency of a given element in a list of numbers.
Please do not copy from a site...if you know it please answer.
Thank you

Answers

Answered by anindyaadhikari13
9

\texttt{\textsf{\large{\underline{Solution}:}}}

>> Using count() method, we can easily count the frequency of an element in the list.

Syntax: list . count(element)

Here,

  • list - Name of list.
  • element - The element whose frequency is to be calculated.

Here comes the program.

n=int(input("How many elements for the list?? "))

a=[]

print("Enter the elements...")

for i in range(n):

   a . append(int(input(">> ")))

count=int(input("Enter element to count its frequency: "))

print("\nGiven List:",a)

print("Frequency of",count,"in the list is:", a . count(count))

See the attachment for output.

Attachments:
Similar questions