python⽤户登陆

⽤户登陆(三次输错机会)且每次输错误时显示剩余错误次数(提示:使⽤字符串格式化)

count = 3
while count < 4:
    count -= 1
    username = input('Name: ').strip()
    passwd = input('Password: ').strip()
    if username == 'admin' and passwd == '123':
        print('成功')
        break
    else:
        print(f'失败,剩余{count}次')
        if count == 0:
            print('请重新运行')
            break
原文地址:https://www.cnblogs.com/zanao/p/10977040.html