Count


#1


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

Oops, try again. Your code looks a bit off--it threw a "invalid literal for int() with base 10: 'one'" error. Check the Hint if you need help!

Well on the console, it does print out the answer expected, but I am still getting an error.


Replace this line with your code. 

def count(sequence,item): 
    count_list = [] 
    item = int(item)
    for i in sequence:
        if i == item:
            count_list.append(i)
    return len(count_list)
    
print count([1, 2, 1, 1] , 1)


#2

Is this line even needed? All that really matters is that the sequence contains items of the same type as item. This program should work with any primitives, int, float, boolean, or string.


#3

man thanks for the help! what a silly mistake that was!
I'll be more careful in debugging next time. This was my first question and
it's good to know that there's help available when needed :wink:


#5