10.4 "return outside function"


Can't understand what the problem is with my code.


Hi @boardsolver27149 ,

The problem is a matter of incorrect indentation. The entire for loop should be indented, so that it is part of the fizz_count function. Then, after that is fixed, the return statement should be indented by the same degree as the for loop header, so that it is not part of the for loop ...

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