lundi 18 mars 2019

Why are two equal variables not considered equal?

When programming something in python I came across this bug where 2 variables that are certainly equal don't count as equal when put through an if X == Y:

Relevant segment of code:

 usernameinput = input("Enter your username: ")
    print("Just a sec...")
    passwordinput = hashingAlgorithm2()
    for line in Database:
        IDNumber, Username, Password = line.split(",")
        if Username == usernameinput:
            print(passwordinput)
            print(Password)
            if passwordinput == Password:            (this is the line in question)
                print("Test")
                LoggedIn = True
                ID = IDNumber
    if LoggedIn == False:
        triesLeft = triesLeft - 1
        print("Your username or password is wrong, you have", triesLeft ,"tries left.")
        if triesLeft <= 0:
            The_Correct_Password

Relevant results:

Enter your username: daniel
Just a sec...
Enter your password: **********
12894487843593301576106844
12894487843593301576106844

Your username or password is wrong, you have 2 tries left.

Does anyone know why this is happening?

I have no clue as to what even is the problem, as both variables are shown to be equal at the time of the if X == Y:

Aucun commentaire:

Enregistrer un commentaire