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

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

相关文章:

  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2021-08-18
  • 2021-05-20
  • 2021-08-16
  • 2022-02-09
  • 2021-10-26
猜你喜欢
  • 2021-06-19
  • 2021-08-15
  • 2021-11-30
  • 2021-08-10
  • 2021-04-27
  • 2021-08-30
  • 2021-07-07
相关资源
相似解决方案