class Bag: """ Bag implemented as an array """ def __init__ ( self ): """ Create an empty Bag """ self.array = [] # an empty array def add(self , item ): """ Adds an item to the bag """ self.array += [ item ] def contains (self , item ): """ Checks if an item is in the bag , returns True or False """ for i in range (len( self . array )): if self.array [i] == item : return True return False def remove (self , item ): """ Removes an item from the bag and returns it. What to do if its not in there ? """ index = 0 for i in range (len( self . array )): if self.array [i] == item : index = i break stuff = self.array [ index ] self.array = self.array[0: index] + \ self.array[index + 1: len(self.array)] return stuff def is_empty(self): """ Check to see if the bag is empty""" return len(self.array) == 0 def iterator ( self ): """ Returns an iterator for the bag """ pass