【Python】流程控制
Python流程控制
if
x = int(input('please enter an integer:'))
if x < 10:
print('less than 10')
elif x == 10:
print('equal 10 ')
else:
print('more than 10')
for
nums = [1, 2, 3, 4, 5, 6]
for n in nums:
print(n)
range()
function
for i in range(5):
print(i)
output: [0,5)
break
andcontinue
for i in range(10):
if i % 2 == 0:
continue
elif i == 5:
break
else:
print(i, ' is odd number')
1 is odd number
3 is odd number
pass
doing nothing
n = 1
if n == 1:
pass
else:
print('complete')