break:直接跳出整个循环
continue:跳出本次循环,接着进行下次循环
code
number = 59
while True:
guess = int(input("enter an integer: "))
if guess == number:
break
elif guess <number:
print("the number is higher than that ")
continue
else:
print("the number is lower than that ")
continue
print("bingo you are right")
print("done")
pass:执行完下面的内容,再返回开始处,进行下一轮的循环
code(注意continue和pass的区别)
a_list = [0,1,2]
print("using continue")
for i in a_list:
if not i:
continue
print(i)
print("using pass")
for i in a_list:
if not i:
pass
print(i)
console
using continue
1
2
using pass
0
1
2