I am trying to have a login system where user input will be crosschecked with tinydb’s json file. I managed to get the registration working but when I try logging in I got this error.
TypeError: unsupported operand type(s) for &: ‘list’ and ‘QueryInstance’
I tried removing password verification and it worked. Not entirely sure the reason behind it. Would be great if I can receive some guidance as to what went wrong. Thanks!
JavaScript
x
11
11
1
def login():
2
username = input("Enter Username: ")
3
password = input("Enter Password: ")
4
User = Query()
5
if(db.search(User.username == username) & (User.password == password)):
6
print("Login Successful!")
7
loggedInScreen()
8
else:
9
print("Incorrect Username or Password")
10
login()
11
Advertisement
Answer
It should have been and
not &
. The operand and
will check both the conditions that you are trying to validate whereas &
does a bitwise AND and it doesn’t like the types of data provided for the bitwise
AND, hence the error.