title: builtins.IndexError: list index out of range
body: <p>I have this function here:</p>
  
  <pre><code>def swap_cards(deck, index_deck):
      swap_deck = []
      after_index = []
      bandf_index = []
      if index_deck &gt;= len(deck):
          for i in range(0, len(deck) + 1):
              if deck[i] == index_deck:
                  after_index += [deck[0]]
              else:
                  bandf_index += [deck[i]]
          swap_deck += [deck[index_deck]] + bandf_index[1:index_deck - 1] + after_index
  </code></pre>
  
  <p>Every time I try to input an index that is greater than or equal to the deck length I get the error 'list index out of range'</p>
  
  <p>Example:</p>
  
  <pre><code>swap_cards([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 9)
  </code></pre>
  
  <p>I expect <code>[9, 1, 2, 3, 4, 5, 6, 7, 8, 0]</code> but am instead getting 'list index out of range'.</p>
  
  <p>Switching the last and the first number, I don't know what I am doing wrong.</p>