break,continue的区别
2019-04-10 13:36 Loker-X 阅读(170) 评论(0) 编辑 收藏 举报break 终止循环,
continue 跳出本次循环,进入下一次循环
username = 'Loker'
passwd = '123456'
for i in range(3):
user = input('请输入您的用户名:')
password = input('请输入您的密码:')
if user == username and password == passwd:
print('welcome,%s'%user)
break
else:
print('sorry.your username or password is false')
---------------------------------------------------------------------------------------
username = 'Loker'
passwd = '123456'
for i in range(3):
user = input('请输入您的用户名:')
password = input('请输入您的密码:')
if user == username and password == passwd:
print('welcome,%s'%user)
continue
else:
print('sorry.your username or password is false')
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步