print("Enter your name:")
myName = input ()
if myName == "Akib":
print("Enter your password")
password = input()
password = "toma"
if password == "toma":
print("Access granted")
else:
print("Not granted")
password = "password" # store your password here
name = "name" # store your name here
input_name = str(input("> enter your name: "))
input_password = str(input("> enter your password: "))
if input_name == name and input_password == password:
print("access granted !")
else:
print("declined !")
可以这样做-所以。 希望这能有所帮助:)
问题是您将password
设置为输入,然后通过将其设置为toma
来休息password
,因此您需要删除password=“toma”
。
print("Enter your name:")
myName = input ()
if myName == "Akib":
print("Enter your password")
password = input()
if password == "toma":
print("Access granted")
else:
print("Not granted")
您可以实现您想要的功能,就像这样!
在这种情况下,如果输入的名称不是'akib',它甚至不会提示用户输入密码。
# prompt for name
myName = input("Enter your name: ")
# check if name is correct
if myName == "Akib":
# prompt for password
password = input("Enter your password: ")
# check if password is correct
if password == "toma":
print("Access granted")
else:
print("Not granted")
else:
print("Not granted")