List + function


#1

I am stuck on list + function exercise. For some reason it gives me error message. I'd really appreciate your help. 

My code: 

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

#2

here:

total = count+1

why store result of count+1 in total? count will stay zero, so total will just get re-assigned a value of 1 of every time

a function ends the moment a return keyword is reached, so your function ends the moment a match is found. To get the correct total, the whole loop needs to finish running successfully


#3

got it silly me.Thanks for the help !!


#4

How did you fix it? Still stuck.


#5

#6

Make a new (linked) topic, hijacking topics like you did now will clutter the topic

fill in the template so we have all the details (code, question (what you don't understand), error message and so on)