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

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

Count error

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


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