title: Code exits for no apparent reason with no error message while using True and False statements to switch from one loop to another
body: <p>So I was just working on a tic tac toe offline game where it uses True and False statements to switch from Player 1 to Player 2. A list keeps track of how many tiles are left as strings (&quot;tile 1&quot;,&quot; tile 2&quot;, etc). So what I did was keep <code>player1turn = True</code> before the game began and then after Player 1 chooses a tile, <code>player1turn = False</code>. If player 1 chooses Tile 1, then tile 1 is removed from the list. But when I run the code, Player 1 can do his move, and player 2 can only do it once because after that the code exits with no error message. My Pycharm IDE is also not telling me about any errors that could have caused this bug. My full script:</p>
  <pre><code>'''
  Name : Tic Tac Toe
  Purpose : A Simple Tic Tac Toe Game With 1 friend
  Plan : Make the board with | and. and _
          Mark each box from 1-9
          Ask the user for input.
          Anything more than 9 or less than 1 will result in a message &quot;Too Big&quot; or &quot;Too Small&quot; and won't restart the game
          A tile already taken will result in a message&quot;Already Taken&quot; and won't restart the game.
          If possible, X or O option will be there.
  '''
  
  print(&quot;Welcome to the tic tac toe offline made by Command Blocks!&quot;)
  
  print(&quot;Player 1 will play first as X&quot;)
  print(&quot;Player 2 will play second as O&quot;)
  player1turn = True
  r1 = 1
  r2 = 2
  r3 = 3
  r4 = 4
  r5 = 5
  r6 = 6
  r7 = 7
  r8 = 8
  r9 = 9
  
  def board():
      print(&quot;._______._______._______.\n|  &quot;, r1, &quot;  |  &quot;, r2, &quot;  |  &quot;, r3, &quot;  |\n|       |       |       |&quot;)
      print(&quot;._______._______._______.\n|  &quot;, r4, &quot;  |  &quot;, r5, &quot;  |  &quot;, r6, &quot;  |\n|       |       |       |&quot;)
      print(&quot;._______._______._______.\n|  &quot;, r7, &quot;  |  &quot;, r8, &quot;  |  &quot;, r9, &quot;  |\n|       |       |       |\n._______._______._______.&quot;)
  
  
  a_p = [&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;, &quot;8&quot;, &quot;9&quot;]
  board()
  print(&quot;available places are:&quot;,a_p)
  while a_p != [] and player1turn == True:
          y_m = input( &quot;Player 1 please enter your input:\n&quot;)
          try:
              if y_m == &quot;1&quot;:
                  a_p.remove(&quot;1&quot;)
                  r1 = &quot;X&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = False
  
  
              elif y_m == &quot;2&quot;:
                  a_p.remove(&quot;2&quot;)
                  r2 = &quot;X&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = False
  
              elif y_m == &quot;3&quot;:
                  a_p.remove(&quot;3&quot;)
                  r3 = &quot;X&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = False
  
              elif y_m == &quot;4&quot;:
                  a_p.remove(&quot;4&quot;)
                  r4 = &quot;X&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = False
  
              elif y_m == &quot;5&quot;:
                  a_p.remove(&quot;5&quot;)
                  r5 = &quot;X&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = False
  
              elif y_m == &quot;6&quot;:
                  a_p.remove(&quot;6&quot;)
                  r6 = &quot;X&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = False
  
              elif y_m == &quot;7&quot;:
                  a_p.remove(&quot;7&quot;)
                  r7 = &quot;X&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = False
  
              elif y_m == &quot;8&quot;:
                  a_p.remove(&quot;8&quot;)
                  r8 = &quot;X&quot;
                  board()
                  print(&quot;available places are&quot;, a_p)
                  player1turn = False
  
              elif y_m == &quot;9&quot;:
                  a_p.remove(&quot;9&quot;)
                  r9 = &quot;X&quot;
                  board()
                  print(&quot;available places are&quot;, a_p)
                  player1turn = False
  
              else:
                  print(&quot;Please enter a number from 1-9&quot;)
  
  
  
          except ValueError:
              print(&quot;That spot is already taken !&quot;)
  
  while a_p != [] and player1turn == False:
          y_m = input( &quot;Player 2 please enter your input:\n&quot;)
          try:
              if y_m == &quot;1&quot;:
                  a_p.remove(&quot;1&quot;)
                  r1 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
  
              elif y_m == &quot;2&quot;:
                  a_p.remove(&quot;2&quot;)
                  r2 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              elif y_m == &quot;3&quot;:
                  a_p.remove(&quot;3&quot;)
                  r3 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              elif y_m == &quot;4&quot;:
                  a_p.remove(&quot;4&quot;)
                  r4 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              elif y_m == &quot;5&quot;:
                  a_p.remove(&quot;5&quot;)
                  r5 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              elif y_m == &quot;6&quot;:
                  a_p.remove(&quot;6&quot;)
                  r6 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              elif y_m == &quot;7&quot;:
                  a_p.remove(&quot;7&quot;)
                  r7 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              elif y_m == &quot;8&quot;:
                  a_p.remove(&quot;8&quot;)
                  r8 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              elif y_m == &quot;9&quot;:
                  a_p.remove(&quot;9&quot;)
                  r9 = &quot;O&quot;
                  board()
                  print(&quot;available places are:&quot;, a_p)
                  player1turn = True
  
              else:
                  print(&quot;Please enter a number from 1-9&quot;)
  
  
  
          except ValueError:
              print(&quot;That spot is already taken !&quot;)
  print(&quot;Won&quot;)
  
  </code></pre>