Count


#1

I used a similar code
def count(sequence,item):
found = 0
for i in sequence:
if item in sequence:
found += 1
sequence.remove(item)
return found

it returns the correct result when I run in pythontutor viz mode ,but here it gives error


Count error
#2

why would you remove items from sequence? There is no reason for it, and it was causes the error given index shift occurs succesive items in sequence will not be counted correctly


#3

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