<p>我如何修改这段代码,使3个列表中每个列表都有5个元素,而不是像现在这样;3个列表中有5/10/15个元素?</p>
<pre><code>import random
y = []
def autoSolve():
for i in range(5):
z = random.randrange(1, 10)
y.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(z)
print(y, end="")
for i in range(3):
print("number", i + 1,)
autoSolve()
print()
</code></pre>
<p>将<code>y = []</code>移到autoSolve方法中,以便在每次调用时重置它。</p>
<pre><code>def autoSolve():
y = []
for i in range(5):
z = random.randrange(1, 10)
y.append(z)
print(y, end="")
</code></pre>