Unable to understand lists+functions


Hi All,

I am stuck at the following exercise:

I'm getting an error message : "File "python", line 9
SyntaxError: 'return' outside function"

I had written the following piece of code:

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

Please tell me where am I doing a mistake.



There are some issues... lets take a look :slight_smile:

So, you're getting an error

That is because return is outside of your function. Your function can't loop through x because x is not defined. So, it seems like you've forgotten to indent somethings after line 2 of your code. How should we fix that? How do we get x to not to give us an error? :wink: hint: I mentioned what to do in this post.


Thanks so much..I totally screwed up the indentation. Now it's working. :slight_smile: