wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Write a program to find the number of times an element occurs in the list.

Open in App
Solution

Program:
#defining a list
list1 = [10, 20, 30, 40, 50, 60, 20, 50, 10, 30, 50, 30, 24, 45]

#printing the list for the user
print("The list is:",list1)

#asking the element to count
inp = int(input("Which element occurrence would you like to count? "))

#using the count function
count = list1.count(inp)

#printing the output
print("The count of element",inp,"in the list is:",count)


OUTPUT:
The list is: [10, 20, 30, 40, 50, 60, 20, 50, 10, 30, 50, 30, 24, 45]
which element occurrence would you like to count? 10
The count of element 10 in the list is: 2

flag
Suggest Corrections
thumbs-up
11
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Organisation of Data
MATHEMATICS
Watch in App
Join BYJU'S Learning Program
CrossIcon