title: List items being ignored or not detected
body: <p>I am learning Python as my first language, and working on the Old Maid game from How to Think like a Computer Scientist. My code was going into an infinite loop and I can't figure out why so I posted on stack overflow. I was asked to isolate the problem and post less code (good advice) which I have now done.</p>
  
  <p>The Problem: Originally, <code>remove_matches</code> would correctly detect and remove matches for all cards objects, except for Aces. Now that I have duplicated the problem on a smaller scale, it doesn't seem to be removing matches for any card ranks. In the following example, I used matching Aces and matching Kings. Neither match is being detected.</p>
  
  <pre><code>class Card:
  suite_list = ["Clubs", "Diamonds", "Hearts", "Spades"]
  rank_list = ["narf", "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King"]
  # "narf" is being used as a placeholder for the zeroith item, to allow
  # card#'s to match the index #'s
  
  def __init__(self, suite = 0, rank = 0):
      self.suite = suite
      self.rank = rank
  
  def __str__(self):
      return self.rank_list[self.rank]+" of "+self.suite_list[self.suite]
  
  
  
  class Deck:
  def __init__ (self):
      self.cards = []
      for suite in range (4):
          for rank in range (1, 14):
              self.cards.append(Card(suite, rank))
  
  def __str__ (self):
      s = " "
      for i in range (len(self.cards)):
          s = s + " "*i + str(self.cards[i]) + "\n"
      return s
  
  def remove_card(self,card):
      if card in self.cards:
          self.cards.remove(card)
          return True
      else:
          return False
  
  
  class Hand(Deck):
  def __init__ (self, name = " "):
      self.cards = []
      self.name = name
  
  def __str__(self):
      s = "Hand "+ self.name
      return s+ " contains\n" + Deck.__str__(self)
  
  def remove_matches(self):
      count = 0
      for card in self.cards:
          match = Card(3 - card.suite, card.rank)
          print card, " matches ", match
          if match in self.cards:
              self.cards.remove(card)
              self.cards.remove(match)
              print "Hand %s: %s matches %s" % (self.name, card, match)
              count = 1
      return count
  
  Joes_hand = Hand("Joe")
  Joes_hand.cards = [Card(1,1), Card(2,1), Card(1,13), Card(2,13)]
  print Joes_hand
  Joes_hand.remove_matches()
  print
  print Joes_hand
  </code></pre>
  
  <hr>
  
  <p><code>Joes_hand = Hand()</code></p>
  
  <p>First, I create a player named Joe, he has no card objects in his hand yet.</p>
  
  <p><code>Joes_hand.cards = [Card(1,1), Card(2,1), Card(1,13), Card(2,13)]</code></p>
  
  <p>Now I have assigned 4 cards to Joe. </p>
  
  <p><code>print Joes_hand</code></p>
  
  <p>Then I printed Joe's hand so we can see the cards he has.</p>
  
  <p><code>Hand Joe contains
   Ace of Diamonds
   Ace of Hearts
    King of Diamonds
     King of Hearts</code></p>
  
  <p><code>Joes_hand.remove_matches()</code></p>
  
  <p>This is where I run into a problem. <code>remove_matches</code> is supposed to remove cards that match by rank and color. This is possible because rank and suite are built in attributes of my <code>Card</code> objects. I added a print statement inside the <code>remove_matches</code> method:
  <code>print card, " matches ", match</code>, for the purpose of proving that the code is able to identify what a match IS. But for some reason it fails to detect the match, even though it knows what to look for. Therefore, none of the statements following the if statement: <code>if match in self.cards:</code> are being executed.</p>
  
  <p>Output:</p>
  
  <p><code>Ace of Diamonds  matches  Ace of Hearts
  Ace of Hearts  matches  Ace of Diamonds
  King of Diamonds  matches  King of Hearts
  King of Hearts  matches  King of Diamonds</code></p>
  
  <p>Finally I print Joe's hand again to show that none of the cards have been removed.</p>
  
  <p><code>print
  print Joes_hand</code></p>
  
  <p><code>Hand Joe contains
   Ace of Diamonds
   Ace of Hearts
    King of Diamonds
     King of Hearts</code></p>
  
  <p>And here is another look at <code>remove_matches</code>:</p>
  
  <pre><code>def remove_matches(self):
      count = 0
      for card in self.cards:
          match = Card(3 - card.suite, card.rank)
          print card, " matches ", match
          if match in self.cards:
              self.cards.remove(card)
              self.cards.remove(match)
              print "Hand %s: %s matches %s" % (self.name, card, match)
              count = 1
      return count
  </code></pre>
  
  <p>I'm sorry my post is long, I tend to over-explain but I want to make sure that I'm sharing all of my information. Am I missing something obvious? I've been struggling with this for days. Any thoughts would be helpful.</p>
  
  <p>Thanks!</p>