Count Help


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
            counter = counter
    answer = int(counter)
    return answer
print counter([1,2,3], 1)



counter = []

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


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