Can't understand what is wrong with my code-Exercise in' A day at the supermarket - lists + functions'


for my code below :

def fizz_count(x) :
count = 0
for item in x :
if item == “fizz”:
count = count + 1
return count

coke = [“fizz”,“coat”,“fizz”,“car”]

drinks = fizz_count(coke)
print drinks

I keep getting errors like this :

fizz_count([‘fizz’, ‘fizz’, ‘fizz’, 9, 8, ‘fizz’]) returned 1 instead of the correct answer: 4

Is it possible that there is a bug in the tutorial as my code seems quite ok? Can somone please help?-Thanks@


return terminates a function so make sure your return statement is outside of for loop.


Worked! Many thanks!