If Statement To Check If The Value Of A Variable Is In A JSON File
I'm kind of new so try not to judge me. I'm trying to create a little 2d game based on the old 2d Mario. I already have home window, the sign up and login windows, and I've got a j
Solution 1:
According to the code of SU()
, the content inside the JSON file (also the content of players
) should be something like below:
{
"user1": {"password": "pass1", "email": "user1@email.com"},
"user2": {"password": "pass2", "email": "user2@email.com"}
}
So the checking should be:
plusname = E1.get()
plpaword = E2.get()
for player in players:
if plusname == player and plpaword == players[plusname]["password"]:
print("login successful")
break
else:
print("login failed")
That is players["password"]
should be players[plusname]["password"]
instead.
Post a Comment for "If Statement To Check If The Value Of A Variable Is In A JSON File"