5. Control flow

Condition

if True:
    print(True)
elif False:
    print(False)
else:
    print(None)

For loop

for fruit in ['apple', 'banana']:
    print(fruit)

for i in range(10):
    print(i)  # 0 ... 9

While loop

while True:
    print('infinite loop')
    continue
    break

你可能感兴趣的:(5. Control flow)