擅长:python、mysql、java
<p>您可以维护一个count变量(可以递增)并返回一个元组列表</p>
<pre><code>if shape == 'rectangle':
rectangles.append((shape,count))
</code></pre>
<p>或者</p>
<p>在遍历列表时,请使用枚举</p>
<pre><code>for indx, shape in enumerate(rectangles):
print indx,shape
</code></pre>