List + Functions


#1



I am a bit confused on this lesson List + Functions because when i call "fizz_count(["fizz","cat","fizz"])" it doesn't return 2, and it always show something like ". fizz_count(['fizz', 'fizz']) returned 1 instead of the correct answer: 2", and I'm a bit confused!!! Help !!!


# 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"])


"Oops, try again. fizz_count(['buzz', 1, 'buzz']) returned None instead of the correct answer: 0"


#2

HI the return statement should be indent like

    for item in x:
        if item == "fizz":
            count = count + 1
    return count

#3

thanks for the help!!


#4

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