1. continue
count = 1
sum = 0
while count < 100:
if count == 88:
count += 1
continue if count % 2 == 0:
sum = sum - count
else:
sum = sum + count
count += 1
print(sum )
结果:
138
解释:continue:结束当前本次循环,继续执行下一次循环
2024-03-24 20:50:22
1. continue
count = 1
sum = 0
while count < 100:
if count == 88:
count += 1
continue if count % 2 == 0:
sum = sum - count
else:
sum = sum + count
count += 1
print(sum )
结果:
138
解释:continue:结束当前本次循环,继续执行下一次循环