Count


#1


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

Am getting this error, Oops, try again. Your function fails on count([1],7). It returns [] when it should return 0. am not able to find out where my mistakes are. help plz


def count(sequence, item):
    found = []
    for i in  found:
        if i == item:
            
            found=found+1
        
        else:
            found = found
    return found
  

#Thanks for your help and guide


#2

here:

found = []

why is found a list? You want to count the number of items in sequence. For counting, use numbers (integers)


#3

i have set found as a variable by making it equal to zero, but now it is giving me another error

Oops, try again. Does your count function take exactly two arguments: a list and an item to check against that list? Your code threw a "'int' object is not iterable" error.

#4

okay, good first step. Then why do you loop over found? sequence contains the list of which you want to count


#5

it just worked out with that correction, thank you so much...let me now figure it out for better understanding


#9