11. Count


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/2/1?curriculum_id=4f89dab3d788890003000096#


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):
    times=0
    sequence=[]
    item=0
    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


#2

That just wiped out the parameter value.

Did you mean to write,

if i == item:

?


#3

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


#4

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