Count


#1

Getting this error. I'm not dealing with strings anywhere I don't believe, so the error isn't really helping me.


#2

When we write,

for i in sequence:

i is not the index, but the value. sequence.index(i) is the index.

When we write,

for i in range(len(sequence)):

then i is the index.


#3

Thanks for the response, but im getting this error now. Tested in seperate IDE and got the same thing


#4

If we are only comparing values, we don't need an index.

for value in sequence:
    if value == item:

It is also not necessary to sort. The order does not matter.


#5

My problem believe it or not, was just that the print count and return count was "count" and not "counter". Switched both and it worked


#6

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