break语句例题:
输入密码:
第一种
for item in range(3):
pwd=input('请输入密码')
if pwd=='8888':
print('密码正确')
break
else:
print('密码不正确')
第二种
a=0
while a<3:
pwd=input('请输入密码')
if pwd=='8888':
print('密码正确')
break
else:
print('密码不正确')
Continue语句:
输出1-50之间5的倍数
for item in range(1,51):
if item%5==0:
print(item)
第二种:
for item in range(1,51):
if item%5!=0:
continue
print(item)
else语句
还是输入密码的问题:
for item in range(3):
pwd=input('请输入密码')
if pwd=='8888':
print('密码正确')
break
else:
print('密码不正确')
else:
print("对不起,三次均错误")
方法二:
a=0
while a<3:
pwd=input('请输入密码')
if pwd=='8888':
print('密码正确')
break
else:
print('密码不正确')
a+=1
else:
print('对不起,三次输入错误')