Count


#1



Hi,

I am getting desired result but will not let me pass the exercise:
What wrong am I doing?


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

print count([1, 2, 1, 4, 1, 6, 1, 8, 1, 10], 1)


#2

I am getting desired result but will not let me pass the exercise:

No,It's not giving desired result!

hint*
check the expression inside the if-block.


#3

Thanks I got it now :slight_smile:


#4

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