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
total = count+1
why store result of
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
got it silly me.Thanks for the help !!
How did you fix it? Still stuck.
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)