【发布时间】:2018-12-18 04:03:09
【问题描述】:
在下面的代码中,循环似乎不起作用。
powers = []
x = 0
y = 0
z = 1
for x in powers:
powers.append([])
for y in powers[x]:
powers[x].append(z ** y)
z = z + 1
if z < 1001:
continue
else:
break
x = x + 1
y = y + 1
z = 1
print(powers)
但是,当我在终端中运行它时,它只会返回一个空的权力列表。它不显示错误消息。
请帮忙。
【问题讨论】:
-
请先纠正
for循环的缩进。注意for x in powers(powers = []),什么都不做。请提供minimal reproducible example。 -
for y in powers[x]。这一行肯定会给你一个错误。
-
从未听说过调试器?我强烈建议您使用其中之一来了解您的问题所在
-
另外:甚至不清楚您的预期输出是什么