Count Help


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/2/1?curriculum_id=4f89dab3d788890003000096#


Oops, try again. Does your count function take exactly two arguments: a list and an item to check against that list? Your code threw a "'int' object is not iterable" error.


Not sure how to fix this error. Do I need to add the number to the counter sequence too?


def count(sequence,item):
    counter = []
    for i in sequence:
        if i == item:
            counter += 1
        else:
            counter = counter
    answer = int(counter)
    return answer
print counter([1,2,3], 1)


#2

here:

counter = []

why is counter a list? if i want to count, i would use numbers starting at zero


#3

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