Click here to Skip to main content
15,666,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make a sign-in/login system using's db library, i keep running into an issue where i get a TypeError saying that 'NoneType' object is not subscriptable

Code of issue:

def signup():
	username = str(input('Username> '))
	password = str(input('Password> '))
		if db[username]:
			print('username taken!')
	except KeyError:
			db[username] = {


Traceback (most recent call last):
  File "", line 45 in <module>
  File "", line 18, in signup
    if db[username]:
TypeError: 'NoneType' object is not subscriptable

I dont know if it is assigning username/password as the input function, even though it should be returning a string

What I have tried:

I have tried to rework the code multiple times, didnt work
Looked everywhere for an answer but nothing had the same issue that i was looking for
Richard MacCutchan 20-May-22 3:08am    
The message is telling you that you have not initialised db to refer to an actual array.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900