问答详情
源自:4-6 Python之break跳出循环

为什么这个在pycharm运行没反应

>>> num = 2

>>> sum = 0

>>> while True:

if num >= 1000:

break

sum = sum + num

num = num + 2

print(sum)


提问者:weixin_慕移动0314716 2020-11-14 11:06

个回答

  • weixin_慕虎6266149
    2020-11-15 08:36:09

    num = 2

    sum = 0

    while True:

        if num >= 1000:

            break

        sum = sum + num

        num = num + 2

    print(sum)