A Day at the Supermarket, Oh Noes!


Day At The Supermarket

Why Oh Why! I rinse and repeat yet i still couldn't figure out what I did wrong!

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

It was supposed to work... It was supposed to work... :cry:

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

fuzz = ["fizz", "fuzz", "fizz"]
fizzy_fuzz = fizz_count(fuzz)
print fizzy_fuzz

Plz Help...


a function ends the moment a return keyword is reached, this is currently happening in the first iteration of the for loop.

place return outside the for loop so the whole for loop can run


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