Vote count:
0
I am trying to iterate through a list and every time an item is found in the list it should increment found by 1. For example: count([1,2,1,1], 1) should return 3 (because 1 appears 3 times in the list).
def count(sequence, item):
sequence = []
found = 0
for i in sequence:
if i in item:
found+=1
return found
asked 52 secs ago
1 Answer
Vote count:
0
You want to test for equality:
if i == item:
found += 1
answered just now
Aucun commentaire:
Enregistrer un commentaire