Count


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/2/1?curriculum_id=4f89dab3d788890003000096


Oops, try again. Your function fails on count([4, 'foo', 5, 'foo'],5). It returns 0 when it should return 1.


def count(sequence,item):
      found=0
      for x in sequence:
           if x==item:
                return found=found+1
           else:
                 return found


#2

Please post your code. :slight_smile:


#3

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