Count gets the green light, but doesnt return the right result


#1


I get the green light to continue, so the code is accepted. But the return is "0" where it should be "3". Whats going on?


sequence = [1,2,1,1]
item = [1]

def count(sequence, item):
    lst = 0
    for i in sequence:
       if i == item:
           lst += 1
    return lst       
    
print count(sequence, item)


#2

in your case item is a list, in case of the exercise it is an integer.


#3

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