11.count


#1

could anyone tell what is going wrong? thanks

def count(sequence,item):
sequence = []
result = 0
for sth in sequence:
if sth == item:
result += 1
else:
return 0
return result

Oops, try again. Your function fails on count([1],7). It returns None when it should return 0.


#2

It seems like you didn't print out the result, so the function doesn't give an output. I didn't maybe catch all the problems, so can you format your code, please? Guide to code formatting: https://discuss.codecademy.com/t/how-do-i-format-code-in-my-posts/51139


#3

i kinda fixed it ! thank you anyway!


#6