user1 = "aqa code"
pass1 = "uzair123"
username = input("Enter username: ")
password = input("Enter password: ")
while username != user1:
print("Access denied: username is incorrect try again ")
username = input("Enter username again: ")
if username == user1:
print("access granted")
while password != pass1:
print("Password is still incorrect")
password=input("Enter password again: ")
if password == pass1:
print("Access granted")
while password != pass1:
print("Access denied,Password is incorrect")
password=input("Enter password again: ")
if password == pass1:
print("Access granted")
如何將.lower()添加到username/user1,以便在鍵入答案時不區分大小寫?請幫忙。python。如何添加.lower()。
您可以簡單地使用'username.lower()使用
raw_input()
== user1'而不是'用戶名== user1' – ettanany的可能的複製[如何轉換字符串在Python中小寫?](http://stackoverflow.com/questions/6797984/how-to-convert-string-to-lowercase-in-python) – Nikaidoh