4/13 List indices must be integers, not str


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/0/4?curriculum_id=4f89dab3d788890003000096#

Oops, try again. an exception was raised for fizz_count(['fizz', 'buzz']): list indices must be integers, not str

I expected it to return a value of 1.


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


#2

Hey @hciczx,

Python's for loops iterate over the list itself and not indices of the list. So, you do not need to put if x[word] == "fizz", you can simply put if word == "fizz". Hope this clears out your doubts...