11. count (11/15) Help needed :'(


#1

What’s wrong with the code below? Everything seems fine when I print and check, but the lesson insists that there is something wrong :confused:

def count(sequence, item):
  print sequence, item
  count = 0
  while item in sequence:
    sequence.remove(item)
    count += 1
  print count
  return count

#2

i don’t think the exercise likes the removal of items from sequence

We only need to count the number of items in the list, why would we remove them from the list? Its not very efficient.


#3

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