Write a Python function to count the number of occurrences in list


Topic: Write a Python function to count the number of occurrences in list

Solution

def countX(lst, x): 
    return lst.count(x) 
lst = [8, 6, 8, 10, 8, 20, 10, 8, 8] 
x = 8
print('{} has occurred {} times'.format(x, countX(lst, x))) 



List all Python Programs