May-12-2022, 09:02 PM
(This post was last modified: May-12-2022, 11:01 PM by deanhystad.)
You can convert a str to an int.
userInputPassword = int(self.PasswordInput.text())But now you have to worry about the user typing something that cannot be converted to an int, like "cat" or even "1.0". To be safe you should wrap the dangerous conversion inside a try except.
try: userInputPassword = self.PasswordInput.text() except ValueError: #Do something here to handle the errorBut this adds a lot of complication to the code. And for what? Why do you want to convert the str to an int? Are you going to do math with the passwords? Does the numerical value of the password have some significance? Why not make the passwords all str?
admins = { "Admin" : "1234", "Joe" : "0000", "Randall" : "1111" }If there is no reason for it t be a number, and it is more convenient for it to be a str, let it be a str.