Я пытаюсь разработать простую систему паролей. Работает с функцией проверки 3 операторов if. Проблема в том, что даже когда пароль правильный, он не запускает первый оператор if. Кажется, переменная entry
никогда не равна переменной password
, но я не знаю почему.
##user input space
entry=Entry(top,bd=5)
entry.pack(side=LEFT)
##actual password to be set
password="abc"
number_of_guesses=0
##function to check user input
def r():
global entry,password,number_of_guesses
number_of_guesses+=1
if entry==password and number_of_guesses<5:
root=Tk()
text=Text(root)
text.insert(INSERT,"You shall pass\nAttempts used:")
text.insert(INSERT,number_of_guesses)
text.pack()
elif number_of_guesses<5 and number_of_guesses>0:
root=Tk()
text=Text(root)
text.insert(INSERT,"Wrong password\nYou used ")
text.insert(INSERT,number_of_guesses)
text.insert(INSERT,"/5 attempts")
text.pack()
elif number_of_guesses>=5:
root=Tk()
text=Text(root)
text.insert(INSERT,"Wrong password\nYou used ")
text.insert(INSERT,number_of_guesses)
text.insert(INSERT,"/5 attempts")
text.insert(INSERT,"\nAccess denied\n")
text.pack()