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
posted @ 2019-06-04 23:59  爱咋闹  阅读(144)  评论(0编辑  收藏  举报