title: Python: 'NoneType' object is not subscriptable' error
body: <p>I'm new to databases in Python, so to practice some key skills I'm building a login screen that writes usernames and hashed passwords to the database, and then checks the user's inputs against what's in the database. However, when trying to pull the usernames and passwords from the database and storing them in variables, I keep getting the "'NoneType' object is not subscriptable" error.</p>
  
  <p>How can I fix this?</p>
  
  <p>This is the function from my program that contains the error</p>
  
  <pre><code>def login():
  usernameAttempt = input("Enter your username: ")
  passwordAttempt = input("Enter your password: ")
  
  usernameSql = """SELECT Username FROM Details WHERE Password = '%s'""" % (passwordAttempt) # Selecting username in database
  cur.execute(usernameSql)
  usernameSql = cur.fetchone()
  userFetched = usernameSql[0] # Pulling the item from the database
  
  passwordSql = """SELECT Password FROM Details WHERE Username = '%s'""" % (usernameAttempt)
  cur.execute(passwordSql)
  passwordSql = cur.fetchone()
  passFetched = passwordSql[0]
  
  dbPassword, dbSalt = passFetched.split(":")
  
  return dbPassword, dbSalt, passwordAttempt, usernameAttempt, userFetched, passFetched
  </code></pre>
  
  <p>I expected the variables userFetched and passFetched to be assigned the values held at indexes 0 in the username and password columns, but the error messages are as follows:</p>
  
  <p>Traceback (most recent call last):</p>
  
  <p>File "C:\Users\laure\Documents\Login screen.py", line 57, in 
      dbPassword, dbSalt, passwordAttempt, usernameAttempt, userFetched, passFetched = login()</p>
  
  <p>File "C:\Users\laure\Documents\Login screen.py", line 34, in login
      userFetched = usernameSql[0] # Pulling the item from the database
  TypeError: 'NoneType' object is not subscriptable</p>