Python 11.count

define a function called count that has two arguments called sequence and item.
return the number of times the item occurs in the list.

def count(sequence,item):
found = 0
for i in sequence:
if i == item :
return found

语法for item in list,在这里不能用item,因为后面有一个,那就选择其它的,如 i

你可能感兴趣的:(Python 11.count)