11/count


#1

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

error:Oops, try again. Your code looks a bit off--it threw a "string index out of range" error. Check the Hint if you need help!

please i want youre help

def count(sequence, item):
     c = 0
     for element in sequence:
         for i in range(len(sequence)):
             for j in range(len(element)):
                 if sequence[i][j] == item:
                     c += 1
     return c

#2

why do you have so many loops? All you need is one loop to loop over sequence, then one if condition to check if the element in the list matches the item you want to have, then increase c and that is it


#3

youre right ,thankyou so much
i wrote it in the case that exist a list inside sequence
def count(sequence, item):
c = 0
for element in sequence:
if element == item:
c += 1
return c