当前位置: 代码迷 >> 综合 >> 4.3 continue和pass和break
  详细解决方案

4.3 continue和pass和break

热度:39   发布时间:2024-02-19 16:38:41.0


#   
# number=59
# while True:
#     guess=int(input("enter an inteher:"))
#     if guess ==number:
#         break 
# #跳出该处所有循环
#     elif guess <number:
#         print("lower")
#         continue
# #跳出当前循环
#     else:
#         print("highter")
#         continue
#  
# print("right")
# print("done")

a_list =[0,1,2]
print("using continue:")
for i in a_list:
    if not i:
        continue
    print(i)

print("using continue:")
for i in a_list:
    if not i:
        pass 
#pass忽略当前,继续进行下面的代码
    print(i)
 

  相关解决方案