Count


#1



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


#2

i tried removing range, sequence[i] == item one by one.. nothing is working.
simply showing error of returning 0 not 1


#3

Your return is inside the for-in loop. So the first time the code reaches return, it ends the whole for-in loop. To solve this, you just need to remove the indentation in front of the return.


#4

awesome... thank you so much


#5

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