As the activity says:
The item you input may be an integer, string, float, or even another list!
So I assumed that if the item appears as a string, it should be counted as well.
Therefore in my if statement, i converted datatype to int and add it to count if it equals to item.
On console, it reflects the expected output but I received this error message:
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!
what does this mean?
def count(sequence,item): #define variable to count number of times 'item' appears in 'sequence' count = 0 for each in sequence: #convert each in sequence to int and compare to item if int(each) == item: #if each equals item then add to count by 1 count += 1 return count print count([7,7,7,7,7,7,7,7],7) #8 print count([1.0,1,2,'1'],1) #3