Can Not Get "while" Statement To Progress
I had previously made a simple logging in code and it was working but when i went to separate data from the code to another .py file and import it, it will not progress passed the
Solution 1:
The issue is in this line:
whileusername!=logindata.user1orusername!=logindata.user2:
If user1
and user2
are different, than the condition will always evaluate to false. You'll want to use and
rather than or
.
Also, you'll probably want to connect the username & password, and not allow user1 to login with the password for user2 and vice versa ...
Solution 2:
Change the or
to an and
.
username = ""while username != logindata.user1 and username != logindata.user2:
print ("Username: ")
username = input()
password = ""while password != logindata.passw1 and password != logindata.passw2:
print ("password")
password = input()
When you type in something that matches logindata.user1
, user != logindata.user2
evaluates to True
and the loop continues. Therefore, you need the username to not match bothlogindata.user1
andlogindata.user2
. Same goes for the password.
Post a Comment for "Can Not Get "while" Statement To Progress"