Python基本循环实例Day 1

发布时间:2019-05-23 21:31:54编辑:auto阅读(1929)

      输入正确的用户名和密码,显示登陆界面,超过三次输入错误则锁定,定义字符串记得加上单引号,数字可以int定义,while循环和if循环语句后加上:,break不加:

    print("---------Welcome to Memory Card Hotel!-------")
    _username = 'wryyy'
    _password = 123
    count = 0
    while count <3:
    username = input("username:")
    password = int(input("password:"))
    if _username == username and _password == password:
    print("Logining now...Welcome {name}!".format(name = _username))
    break
    else:
    print("Invalid username or password.")
    count = count +1
    else:
    print("LOCKED ON,you have tried too many times.")


关键字