<p>我需要用Python编写一个代码,使用while循环返回列表中的第一个正数。这就是我所拥有的,但它不起作用</p>
<pre><code>def positive(num):
n= num[0]
### Can't change anything above
</code></pre>
<p>首先,我尝试:</p>
<pre><code> i = 0
while n <= 0:
i += 1
</code></pre>
<p>但那不起作用,所以我试着:</p>
<pre><code> i = 0
while i < len(num):
n = num[i]
while n <= 0:
i += 1
##### Can't change below
return n
</code></pre>
<p>我觉得我知道如何使用while循环,但改变列表的索引却让我大吃一惊</p>