4. list and functions


#1



I have no idea whats going wrong here


i get the result: fizz_count(['fizz', 'buzz']) returned 0 instead of the correct answer: 1


# Write your function below!
def fizz_count(x):
    count=0
    for item in x:
        if x == "fizz":
            count=count+1
    return count

please help me out


#2

item will hold (in turn) the items in the list, so you should compare fizz with item not with x (the whole list)


#3

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