continue语句、while循环
_username = "gsk"
_password = "123a"
num = 0
while num < 3:
username = input("请输入用户名:")
password = input("请输入密码")
if username == _username and password == _password:
print("爱你 %s login..." %_username)
break
else:
print("用户名或密码输入错误")
num += 1
else:
print("输入次数超过三次")
添加判断,选择是否继续玩
_username = "gsk"
_password = "123a"
num = 0
while num < 3:
username = input("请输入用户名:")
password = input("请输入密码")
if username == _username and password == _password:
print("爱你 %s login..." %_username)
break
else:
print("用户名或密码输入错误")
num += 1
if num == 3:
sum = input("还想继续玩吗[y/n]")
if sum == "y":
num =0
else:
print("输入次数超过三次")