11.Count


#1




Seriously, this Pratice Makes Perfect thing is eating me alive...


it shows me this error: Oops, try again. Your function fails on count([4, 'foo', 5, 'foo'],5). It returns False when it should return 1.
WHAT AM I DOING WRONG? WHAT DOES 'FOO' MEAN? PLEASE HELP!!


def count(sequence, item):
    found = 0
    for num in sequence:
        if num == item:
            found += 1
        else:
            return False


#2

a function ends the moment a return keyword is reached, this happens the moment an item form the list does not equal item

No need to return false, simply return found after the loop has finished running


#3

WOW, NOW IT IS FIXED, thank you!!!! :rose:


#4