• 用while实现登录操作(3次过后,输入yes,使counter置0,还可以玩)


                                                     用while实现登录操作(输入yes,使counter置0,还可以玩)
    #_author:Administrator
    #date:2019/10/24
    user_name="star"
    passwoed='123'

    counter=0
    while counter<3:
    u_username=input("please input your username:")
    u_password=input("please input your password:")

    if u_username==user_name and u_password==passwoed:
    print("welcome to %s"%u_username)
    break
    else:
    print("your username or password is Error")
    counter += 1
    if counter==3:
    print("Do you want to play? please choose[yse/no]")
    keep_going=input("your choose:")
    if keep_going=="yes":
    counter=0
    else:
    print("Go away")
    Output:

    please input your username:a
    please input your password:a
    your username or password is Error
    please input your username:a
    please input your password:a
    your username or password is Error
    please input your username:a
    please input your password:a
    your username or password is Error
    Do you want to play? please choose[yse/no]
    your choose:yes
    please input your username:
    please input your password:a
    your username or password is Error
    please input your username:a
    please input your password:a
    your username or password is Error
    please input your username:
    please input your password:a
    your username or password is Error
    Do you want to play? please choose[yse/no]
    your choose:a
    Go away

  • 相关阅读:
    bisect in Python
    1385. 两个数组间的距离值
    面试题 04.08. 首个共同祖先
    Python关键字yield
    1237. 找出给定方程的正整数解
    响应式文字
    java环境变量设置
    小 div在大 div中左右上下居中
    清除浮动
    jQuery 图片等比缩放
  • 原文地址:https://www.cnblogs.com/startl/p/11732564.html
Copyright © 2020-2023  润新知