I'm trying to make a sign-in/login system using replit.com'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> '))
try:
if db[username]:
print('username taken!')
except KeyError:
db[username] = {
'Username':username,
'Password':password,
'Money':50,
'TotalBetting':0,
'TotalProfit':0,
}
print(db[str(username)])
Error:
Traceback (most recent call last):
File "main.py", line 45 in <module>
signup()
File "main.py", 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