title: Solitaire python
body: <p>I have code here for moving a card from the deck to the foundation pile. I've imported the necessary details, etc. My problem is, it's too long. Is there any way to make it shorter? How? Thanks :)</p>
  
  <pre><code>def dtof():
      suit = raw_input("enter suit: ")
      v = trash.pop()
      if suit == "D":
          if card.suitNumber[v.suit] == 1:
              if card.rankNumber[v.rank] == 0:
                  Diamond.append(v)
              elif card.rankNumber[v.rank] == card.rankNumber[Diamond[-1].rank] + 1:
                  Diamond.append(v)
              else:
                  trash.append(v)
              return Diamond[-1]
          else:
              trash.append(v)
      elif suit == "H":
          if card.suitNumber[v.suit] == 2:
              if card.rankNumber[v.rank] == 0:
                  Heart.append(v)
              elif card.rankNumber[v.rank] == card.rankNumber[Heart[-1].rank] + 1:
                  Heart.append(v)
              else:
                  trash.append(v)
              return Heart[-1]
          else:   
              trash.append(v)
      elif suit == "C":
          if card.suitNumber[v.suit] == 4:
              if card.rankNumber[v.rank] == 0:
                  Clubs.append(v)
              elif card.rankNumber[v.rank] == card.rankNumber[Clubs[-1].rank] + 1:
                  Clubs.append(v)
              else:
                  trash.append(v)
              return Clubs[-1]
          else:
              trash.append(v)
      elif suit == "S":
          if card.suitNumber[v.suit] == 3:
              if card.rankNumber[v.rank] == 0:
                  Spade.append(v)
              elif card.rankNumber[v.rank] == card.rankNumber[Spade[-1].rank] + 1:
                  Spade.append(v)
              else:
                  trash.append(v)
              return Spade[-1]
          else:
              trash.append(v)
      else:
          trash.append(v)
  </code></pre>