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
9
>> 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:
![](https://hi-static.z-dn.net/files/d78/f9e778614b1318a04504e83353ccd9c9.jpg)
Similar questions