Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to count the appearance of number or string in a list python

def count_apperace(list,number_or_string_to_find):
    count = 0 
    for item in list:
        if item == number_or_string_to_find:
            count += 1
    return count

print("the number 3 has occured ",count_apperace([1,27,53,6,74,2,3,4,3,77,8],3),"times")
 
PREVIOUS NEXT
Tagged: #count #appearance #number #string #list #python
ADD COMMENT
Topic
Name
4+7 =