本文介绍了Python While/For循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使它进入while循环并输出相同的内容??
how can I make this into a while loop and output the same thing????
for x in range(56,120) :
if (x < 57) :
summation = 0
summation = x + summation
if (x == 119) :
print ("Sum of integers from 56 to 120 is", summation)
推荐答案
summation = 0
start_val = 56
stop_val = 120
while start_val < stop_val:
summation += start_val
start_val += 1
print summation
这篇关于Python While/For循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!