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!


#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!


def count(sequence,item):
    total = 0
    
    for num in sequence:
        num2 = int(num)
        if item == num2:
            total+=1
        return total


#2

why do you have this line:

num2 = int(num)

not all items in the list are integers, remove this line. Also, a function ends the moment a return keyword is reached the function ends, which in your case happens in the first run of the loop, you might want to change the indent of return so the whole for loop can run


#3

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