How to create a while loop to cycle through a list and count instances of a certain word? Python -
this question has answer here:
i thinking, how make while loop cycle through list , count instances of word 'hello' example.
list = ['bob','hello','jacob','hello','count']
so expected output 2.
just use count
(bonus: have "count" item in list ^^):
>>> ['bob','hello','jacob','hello','count'].count('hello') 2
Comments
Post a Comment