I need help:
I want to write function that: takes a list as a input and return count of specific string.
If function input is x=[a,a,b,c]
function need return 2
(a
is two times in this list).
I need help:
I want to write function that: takes a list as a input and return count of specific string.
If function input is x=[a,a,b,c]
function need return 2
(a
is two times in this list).
>>> def F(seq, string):
return seq.count(string)
>>> F(['a','a','b','c'], 'a')
2
Equivalent to:
def F(seq, string):
n = 0
for x in seq:
if x == string:
n += 1
return n