第二天,三次登录

#用户登录3次机会
i = 0
while i < 3 :
    username = input("请输入用户名:")
    password = int(input("请输入密码:"))
    if username == 'cxr' and password ==123:
        print('Sucessed')
    else:
        print('failed,plz try again')
    i += 1
print('out')

  

 

占位符

#格式化输出
# % s d
name = input('plz input name:')
age = input('plz input age:')
height = input('plz input height:')
msg = "我叫%s,今年%s,身高%s" %(name,age,height)
print(msg)

 

while else

当循坏被break打断,则不执行else

当循环没有被打断,(pass)则执行else

 

posted @ 2023-07-20 10:50  antonrr  阅读(15)  评论(0)    收藏  举报