11. Count



Your function fails on count([4, 'foo', 5, 'foo'],5). It returns 0 when it should return 1

To print 1

Replace this line with your code. 
def count(sequence,item):
    for i in sequence:
        if sequence == item:
            times += 1
            print times
    return times

I really dont know what im i doing wrong i saw an estament if type(i) == list iterates trough a new for , but i dont understand it totally, hope a moderator can bring some light here


That just wiped out the parameter value.

Did you mean to write,

if i == item:



Already fixed! Im defining variables where python doesnt need´em, brought that from C++ haha, thanks a lot for the if too, worked just fine


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