A Day at the Supermarket 4


Hello Ladies and Gents, Good Morning to you all? I have ran into a problem in my code:

# Write your function below!
def fizz_count(x):
    count = 0
    for f in x:
     if f == 'fizz':
        count = count + 1
        return count

This is the error I get:Oops, try again. fizz_count(['fIzZ', 'fizz', 'buzz', 4, 'fizz', 'fizz']) returned 1 instead of the correct answer: 3


your return statement is in the for loop. it needs to be outside


Now it tells me that return is outside function


it should look like this; return statement is outside of for loop, but still inside of the function


OH I see what you mean thank you let's just pray it works!


If it solved your issue flag this thread as solved


It still says the same thing that it is outside the function, I hate it when it does that.


Fixed it I found the error have a nice day!


def fizz_count(x):   #no tab
    count = 0          #one tab
    for f in x:           #one tab
        if f == 'fizz':   #two tabs
            count = count + 1      #three tabs
    return count      #one tab


You Too Sir I had this problem too on a past account