【发布时间】:2020-10-27 08:03:23
【问题描述】:
while True:
print("who is this?")
name=input()
if name!='shubh':
continue
print("hi its you shubh. type your password")
password=input()
if password!="shubh":
print("try again. wrong password")
elif password=="shubh":
break
print("access granted")
当用户提供正确的 id 但密码错误时,代码必须从密码输入而不是从开始运行
【问题讨论】:
-
那么你可能需要两个循环。 1 代表用户名,2) 代表密码。
标签: python while-loop passwords user-input continue