擅长:python、mysql、java
<p>列表中的索引从零开始。</p>
<p>所以,在<code>more_stuff[7]</code>中,你会得到最后一个。</p>
<p>您的代码试图在不存在的<em>'Boy'</em>之后弹出另一个元素。</p>
<p>你需要解决的是:</p>
<pre><code>while len(new_list) <= 7:
</code></pre>
<p><strong>编辑:</strong></p>
<p>你也可以通过列表理解来完成:</p>
<pre><code>more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana",
"Girl", "Boy"]
new_list = [more_stuff.pop() for __ in xrange(len(more_stuff))]
print new_list
</code></pre>