python3.5模拟登陆

python3.5模拟登陆要求:

1、三次登陆认证;

2、输入正确--->欢迎;

3、输入错误--->密码或账户有误;

4、如果想继续--->选择y或Y。

 

思路:

1、创建账户和密码;

2、用while循环,count计数;

3、输入正确时,跳出循环(break);

4、挡count=3时,要重新计数(count置0)。

 

 

 

count = 0
age = 22

while count < 3:
    user_guess = int(input("you guess:"))
    if user_guess == age :
        print("you are right!")
        break
    elif user_guess < age :
        print("try bigger")
    else :
        print("try smaller")
    count += 1

    if count == 3 :
        choice = input("please choice?:(y|Y):")
        if choice == 'y' or choice == 'Y':
            count = 0

 

posted @ 2018-01-13 21:03  米兰的小铁将  阅读(148)  评论(0)    收藏  举报