# Enter a code
num = 0
sum = 0
while True:
if num > 1000:
if num % 2 == 0:
sum = sum + num
num = num + 1
continue
print(sum)
陷入了死循环,当num为1的时候直接跳过if里的语句,导致num一直是1,造成while循环一直为true,一直循环。
num = 0
sum = 0
while num < 1001:
if num % 2 == 1:
num += 1
continue
else:
num += 1
sum = sum + 1
print(sum)
不是偶数也应该+1