DAY 17 of PYTHON top 100 questions : from Basic to Advanced !!

DAY 17 of PYTHON top 100 questions : from Basic to Advanced !!

Write a Python program to find the number of occurrences of a given element in a list :

l=[1,2,3,4,4]
j=4
count=0
for i in l:
    if i==j:
        count+=1
print(count)

Output :

2

It counts the number of occurrences of a given element j in the list l. The output will be the number of times the element j appears in the list l.


If you are a beginner and want to know more about Python programming, you can read my Basics of Python blogs (From part 1 to part 15).


HAPPY LEARNING !!!