我目前正在尝试不同的方法来解决指数(通过加法)。结果一打印出来,我就不能再使用这个程序了。我试过continue和break,但它们不合适x = int(input())y = 0z = xwhile z != 0: y += x z -= 1 if z <= 0: y *= xprint(y)我只需要在之前的结果之后再次重新使用该应用程序,并继续使用它直到它关闭。
1 回答

冉冉说
TA贡献1877条经验 获得超1个赞
您需要将所有内容包装在一个while循环中并给出某种类型的退出条件。
x = input()
while x != 'exit':
x = int(x)
y = 0
z = x
while z != 0:
y += x
z -= 1
if z <= 0:
y *= x
print(y)
x = int(input())
print('You chose to end the program, goodbye!')
添加回答
举报
0/150
提交
取消