擅长:python、mysql、java
<p>请注意,您应该使用<code>range</code>从一个数字到一个数字,并且<code>python</code>索引从<code>0</code>开始,因此您需要以如下方式调整代码:</p>
<pre class="lang-py prettyprint-override"><code>LPL = ["1","2","3"]
f = str()
for i in range (1, len(LPL)+1):
### note that your LPL[0] == 1 and not LPL[1] == 1, so you need to decreasee a number here, that's why a +1 in the range too
if str(i) == LPL[i-1]:
f+=str(i)
### OUTPUT
>>> f
'123'
</code></pre>