11/15 Count Clarifying question on for loop


Does this code not work because “item” is a single number, and not a list?

def count(sequence,item):
total = 0
for s in sequence:
for i in item:
if s == i:
total +=1

return total


Correct. Check if item is in sequence, and how many times it occurs.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.