当前位置: 首页 > 文档资料 > Python 学习笔记 >

while

优质
小牛编辑
137浏览
2023-12-01

基本语法

  • for in
    • rang()
  • while
    • break
    • continue

for in

举例子

for x in [1,2,3]:
    print(x)

while

举例子


while x < 0:
    print(x)
    x --

break 和 continue

for x in [1,2,3,4,5,6,7]:
    if i > 4:
        print('nnon')
        break
    if i == 5:
        print(i)
        continue

rang()

a = rang(9)

>>>>> a = [0,1,2,3,4,5,6,7,8]