title: python tic tac toe game stop and value check function return error
body: <p>I'm trying to run a simple tic tac toe game script in python. I use a list to track in which cell of the table there is a &quot;X&quot;, an &quot;Y&quot; or nothing. to set the value you have to input the coordinate of the cell you want to play in and if the coordinate doesn't exist or it is already occupied, you get an error message and the game ask you to input again. the problem is that whenever i input a number, i get the error message and the program stop. I can't spot the error, can anyone help me?
  the cose is the following:</p>
  <pre><code>class Tris:
      def __init__(self, xo = True):
          self.tabella = [0, 0, 0,
                          0, 0, 0,
                          0, 0, 0]        # -this is the starting table
          self.xo = xo                    # -to check if it is &quot;x&quot; turn or &quot;o&quot; turn
          self.finito = False             # -to check if the game is unfinished
  
  
  
                                          # -just to print grafic style of the table: ignore that
      def print_tabella(self):
          giocatore = &quot;X&quot; if self.xo else &quot;Y&quot;
          tabella_convertita = self.tabella
          for n, i in enumerate(tabella_convertita):
              if i == 0:
                  tabella_convertita[n] = &quot; &quot;
              elif i == 1:
                  tabella_convertita[n] = &quot;X&quot;
              else:
                  tabella_convertita[n] = &quot;O&quot;
          t1 = &quot;|&quot;.join(str(i) for i in tabella_convertita[0:3])
          t2 = &quot;|&quot;.join(str(i) for i in tabella_convertita[3:6])
          t3 = &quot;|&quot;.join(str(i) for i in tabella_convertita[6:9])
          spazio_casella = &quot;-+-+-&quot;
          testo_segnaposto = &quot;&quot;&quot;use following numbers to set X/O:
                      0|1|2
                      -+-+-
                      3|4|5
                      -+-+-
                      6|7|8&quot;&quot;&quot;
          turno_di = f&quot;turn : {giocatore}&quot;
          tab_finale = t1 + &quot;\n&quot; + spazio_casella + &quot;\n&quot; + t2 + &quot;\n&quot; + spazio_casella + &quot;\n&quot; + t3 + &quot;\n&quot;+ testo_segnaposto +&quot;\n&quot; + turno_di
          return tab_finale
  
      def controlla(self, casella):
          if casella.isalpha():       # check if the input is not numerical
              return False
          else:
              if not 0 &lt;= int(casella) &lt;= 8:      # the value must be between 0 and 8
                  return False
              else:
                  return self.tabella[int(casella)] == 0      # the cell must not be containing another symbol
  
      def is_winner(self): # check if there is a row, a column or a diagonal with the same symbol
          lista_righe = [[self.tabella[0], self.tabella[1], self.tabella[2]], [self.tabella[3], self.tabella[4], self.tabella[5]],
                           [self.tabella[6], self.tabella[7], self.tabella[8]]]
          lista_colonne = [[self.tabella[0], self.tabella[3], self.tabella[6]], [self.tabella[1], self.tabella[4], self.tabella[7]],
                           [self.tabella[2], self.tabella[5], self.tabella[8]]]
          lista_diagonali = [[self.tabella[0], self.tabella[4], self.tabella[8]], [self.tabella[2], self.tabella[4], self.tabella[6]], ]
          lista_vincite = [lista_colonne, lista_diagonali, lista_righe]
          winner = False
          for i in lista_vincite:
              for liste in i:
                  if liste[0] == liste[1] and liste[1] == liste[2] and liste[0] != 0:
                      winner = True
                      break
          return winner
  
  
  
      def gioca(self):
          while self.finito == False:                                 # check if the game is finished
              if self.is_winner():                                    # check if there is a winner
                  self.finito = True
                  break
              print(self.print_tabella())                             # print the table in grafic form
              inp = input(&quot;choose a number to set X/O: &quot;)
              if not self.controlla(inp):                             # check if the input is in valid form
                  print(&quot;invalid number or cell already used&quot;)        # or if the chosen cell is available
              else:
                  self.xo = not self.xo                               # to track if it is X turn or O turn
                  if self.xo:
                      self.tabella[int(inp)] = 1
                  else:
                      self.tabella[int(inp)] = 2
  
  gioco_tris = Tris()
  gioco_tris.gioca()
  </code></pre>