# -*- coding: utf-8 -*- # @Time : 2020/7/25 22:45 # @Author : Breeze # @FileName: login_while.py user_name = "Breeze" password = "123456789" counter = 0 while counter < 3: get_username = input("请输入用户名:") get_password = input("请输入密码:") if get_username == user_name and get_password == password: print("Welcom %s login...." % user_name) else: print("Invalid username or password!") counter += 1 if counter == 3: keep_going_choice = input("还想玩吗?[y/n]") if keep_going_choice == "y": counter = 0 else: print("臭不要脸!")