Python的第五天
1、break 和continue
continue:跳过本次循环,进入下一次循环
break:结束当前循环
for i in range(1,6):
print(f"-----------{i} 层----------")
if i == 3:
print("三层坏了")
continue
for j in range(1,9):
if i == 4 and j == 4:
print("遇到鬼屋了,快跑。。。")
break
print(f"{i}-{i}0{j}室")
2、while循环
死循环:
count = 0
while True :
count += 1
print(f"第{count}次循环")
有限制条件:
count = 0
while count < 10:
count += 1
print(f"这是第{count}次循环")
3、九九乘法表
for i in range(1,10):
for j in range(1,i+1):
print(f"{i} * {j} = {i * j}",end= " ")
print()