<p>假设我有以下列表:</p>
<pre><code>common_list = ['Potato', 'Tomato', 'Carrot']
</code></pre>
<p>我想检查<code>common_list[3]</code>是否存在;如果没有,我想添加一些内容。以下是我尝试过的:</p>
<pre><code>if common_list[2] and not common_list[3]:
common_list.insert(3, 'Lemon')
</code></pre>
<p>但它给了我一个错误:</p>
<pre><code>IndexError: list index out of range
</code></pre>