回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在学习python并练习。其中一个是编码一个投票系统,用列表在比赛的23名球员中选出最佳球员。</p>
<p>我在用<code>Python3</code>。</p>
<p>我的代码:</p>
<pre><code>players= [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
vote = 0
cont = 0
while(vote >= 0 and vote <23):
vote = input('Enter the name of the player you wish to vote for')
if (0 < vote <=24):
players[vote +1] += 1;cont +=1
else:
print('Invalid vote, try again')
</code></pre>
<p>我明白了</p>
<blockquote>
<p>TypeError: '<=' not supported between instances of 'str' and 'int'</p>
</blockquote>
<p>但这里没有任何字符串,所有变量都是整数。</p>