python --循环的break 和continue 的区别
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" count = 0 while count < 3: int_username = input("please input your name:") int_password = input("please input your password:") if int_username=="zhansean" and int_password=="19911005": print("gongratulations! you can login") break else: count += 1 print("sorry! the password is wrong or has no this user") if count > 2: print("sorry ,you have login above three times ,please try again after 3 minutes")
每天进步一点点~~