title: How to deal with NoneType error in Python?
body: <p>I have only picked up coding and Python in the past week so this question may seem obvious.</p>
  <p>I am trying to create a card game. I have already created my deck of cards and now I'm trying to make a function to remove a card from the deck and to test that I am printing out the deck of cards.</p>
  <p>However, when I remove a random card from the deck and then try to print out the properties of the remaining cards in the deck I receive an error.
  I created a class called Card with attributes name, value, suit
  I took out parts of the code which were very long and not exactly relevant.
  I have a list of all my cards called the_deck
  I tried to account for the error with</p>
  <p>&quot;if the_deck[i] is None:continue:&quot;</p>
  <p>but that doesn't seem to work.
  Here is my code and then the error.</p>
  <pre><code>def pick_a_card():
      a = random.choice(the_deck)
      print(a.name + &quot; of &quot; + a.suit)
      the_deck = the_deck.remove(a)
      i = 0
      while i &lt;= 51:
          if the_deck[i] is None:
              continue
          else:
              print(the_deck[i].name + &quot; of &quot; + the_deck[i].suit)
          i+=1
  pick_a_card() 
  </code></pre>
  <p>The error I get is</p>
  <p>TypeError: 'NoneType' object is not subscriptable</p>
  <p>This error comes from removing a card from the deck. The rest of the function has no errors.</p>
  <p>How do I fix this?
  Thanks.</p>