python wlile

sum100 = 0
counter = 1

while counter <= 10000000:

    sum100 += counter
    counter += 1
    #print(counter)

print ("result is %d" % sum100)
result is 50000005000000

continue语句

sum100 = 0
counter = 1

while counter <=10:
    counter += 1

    if counter % 2 == 1:
        continue
    print(counter)
    sum100 += counter
print ('sum100=',sum100)

break语句

sum100 = 0
counter = 1

while counter <=10:
    counter += 1

    if counter % 2 == 1:
        break
    print(counter)
    sum100 += counter
print ('sum100=',sum100)
posted @ 2022-08-19 22:58  luoganttcc  阅读(1)  评论(0编辑  收藏  举报