4. Lists + Functions. Can't figure it out


#1



https://www.codecademy.com/en/courses/python-beginner-en-IZ9Ra/0/4?curriculum_id=4f89dab3d788890003000096#


My code returns none instead of the correct response zero.


I expect it to return 2


Replace this line with your code. 
# Write your function below!
def fizz_count(x):
    count = 0
    for item in x:
        if item == "fizz":
            count = count + 1
            return count 
            
fizz_count(["fizz", "cat", "fizz"])


#2

The return statement belongs outside of the loop.

 def fizz_count(x):
    # ...
    return count

#3

which loop? I have several loops


#4

Outside of the for loop, with minimal indentation, as shown above. That is the only loop. btw.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.