Lists + Functions


#1

<PLcode

I keep getting this error: fizz_count([9, ‘fuzz’, 7, ‘fuzz’, ‘buzz’]) returned None instead of the correct answer: 0
I have no idea what to do from here


#2

Is there something I am missing here? How come nobody is helping?


#3

Looks fine, try refreshing the page otherwise copy paste the code to the forum so i can run it

Its a forum, getting help might take a while (depending on who is online)


#4

Thats what I thought, it looks good to me. Ive also tried refreshing and that does not work either.
Heres the code:

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

#5

now your return has the wrong indent level, shoud have the same indent as for like you had it before


#6

Im not sure why it copied that way but I changed it back and it is still not working, I am really confused now.


#7

please post:

code
error message
exercise url


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

fizz_count([‘fuzz’, ‘buzz’, 1, 9, ‘fIzZ’, 5]) returned None instead of the correct answer: 0

https://www.codecademy.com/courses/learn-python/lessons/a-day-at-the-supermarket/exercises/lists--functions?action=lesson_resume


#9

if we add a function call:

def fizz_count(x):
  count = 0
  for item in x:
    if item == 'fizz':
    	count = count + 1
  return count
print fizz_count(["fizz","cat","fizz"])

it perfectly outputs 2. rewrite the return line, i don’t see what is wrong. Otherwise refresh the page


#10

Well I have no idea what the problem was but I reset the workspace and rewrote the whole code and it worked. Thanks a lot for helping me out.


#11