课程
/后端开发
/Python
/初识Python
sum = 0
x = 1
n = 1
while True:
n = n + 1
x = x * 2
sum = sum + x
if n > 20:
break
print sum
2016-12-14
源自:初识Python 5-6
正在回答
sum = 0 x = 1 n = 1 while True: sum = sum + x n = n + 1 x = x * 2 if n > 20: break print sum
sum = sum + x 写到 n = n + 1 前面,放后面的话sum就多加了一次
举报
学python入门视频教程,让你快速入门并能编写简单的Python程序