title: How to fix: "TypeError: 'bool' object is not subscriptable"
body: <p>I am currently working with a basic client/server application and implementing a simple RSA / public-key authentication system. I have ran into this error and can not, for the life of me, figure it out.</p>
  
  <p>I am using the latest version of python.</p>
  
  <p>server.py </p>
  
  <pre class="lang-py prettyprint-override"><code>def getUserData(username):
      global privateKeysFilename
      filename = privateKeysFilename
  
      with open(filename, "r") as keysFile:
          for line in keysFile:
              line = [token.rstrip("\n") for token in line.split(",")]
              if(username == line[0]):
  
                  if DEBUG:
                      print("\n=== DEBUG\nUser data = %s\n===\n" %(line))
  
                  return line
      return False
  
  
  
  def running(self):
      global BUFFER, DEBUG, start, final
  
      while 1:
          print('Waiting for a connection')
          connection, client_address = self.server_socket.accept()
          connection.send("Successful connection!".encode())
  
          x = randint(start, final)
          self.fx = function(x)
          connection.send(str(x).encode())
  
          try:
              # Output that a client has connected
              print('connection from', client_address)
              write_connection()
              # Set the time that the client connected
              start_time = datetime.datetime.now()
  
              # Loop until the client disconnects from the server
              while 1:
                  # Receive information from the client
                  userData = connection.recv(BUFFER)
  
                  #data = connection.recv(1024).decode()
  
                  if(userData != "0"):
  
                      #define split character 
                      ch = ","
  
                      userData = userData.split(ch.encode())
                      username = userData[0]
                      r = int(userData[1])
  
                      userData = getUserData(username)
  
                      e, n = int(userData[1]), int(userData[2])
                      y = modularPower(r, e, n)
  
                      if DEBUG:
                          print("=== DEBUG\ne = %d\nn = %d\nr = %d\ny = %d\n===\n" %(e, n, r, y))
  
                      if(self.fx == y):
                          #if authentication passed
                          connection.send("Welcome!!!".encode())
                      else:
                          connection.send("Failure!!!".encode())
  
  
  
                  if (userData != 'quit') and (userData != 'close'):
                      print('received "%s" ' % userData)
                      connection.send('Your request was successfully received!'.encode())
                      write_data(userData)
                      # Check the dictionary for the requested artist name
                      # If it exists, get all their songs and return them to the user
                      if userData in self.song_dictionary:
                          songs = ''
                          for i in range(len(self.song_dictionary.get(userData))):
                              songs += self.song_dictionary.get(userData)[i] + ', '
                          songs = songs[:-2]
                          print('sending data back to the client')
                          connection.send(songs.encode())
                          print("Sent", songs)
                      # If it doesn't exist return 'error' which tells the client that the artist does not exist
                      else:
                          print('sending data back to the client')
                          connection.send('error'.encode())
                  else:
                      # Exit the while loop
                      break
              # Write how long the client was connected for
              write_disconnection(start_time)
          except socket.error:
              # Catch any errors and safely close the connection with the client
              print("There was an error with the connection, and it was forcibly closed.")
              write_disconnection(start_time)
              connection.close()
              data = ''
          finally:
              if data == 'close':
                  print('Closing the connection and the server')
                  # Close the connection
                  connection.close()
                  # Exit the main While loop, so the server does not listen for a new client
                  break
              else:
                  print('Closing the connection')
                  # Close the connection
                  connection.close()
                  # The server continues to listen for a new client due to the While loop
  
  </code></pre>
  
  <p>and here is the output with error:</p>
  
  <pre><code>
  Traceback &lt;most recent call last&gt;:
      File "server.py", line 165, in running
      e, n = int(userData[1]), int(userData[2])
  TypeError: 'bool' object is not subscriptable
  
  </code></pre>
  
  <p>Any help would be greatly appreciated! :)</p>