标签:while back his wrong this try style lang 代码
break代表结束本层循环,而continue则用于结束本次循环,直接进入下一次循环
continue
##打印1-10 除了7的数字
number=11
while number>1:
number -= 1
if number==7:
continue # 结束掉本次循环,即本次循环continue之后的代码都不会运行了,而是直接进入下一次循环
print(number)
break
username="zhansean" password="19911005" int_username=input("please input your name:") int_password=input("please input your password:") count = 0 while count < 3: if int_username=="zhangsan" and int_password=="19931005": print("gongratulations! you can login") break else: print("sorry! the password is wrong or has no this user") count+=1 print("sorry ,you have login above three times ,please try again after 3 minutes")
python --循环的break 和continue 的区别
标签:while back his wrong this try style lang 代码
原文地址:https://www.cnblogs.com/clairedandan/p/14097740.html