【发布时间】:2023-04-08 14:39:01
【问题描述】:
我正在学习 python 并进行练习。其中之一是编写一个投票系统,以使用列表在比赛的 23 名球员中选出最佳球员。
我正在使用Python3。
我的代码:
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')
我明白了
TypeError:“str”和“int”的实例之间不支持“
但我这里没有任何字符串,所有变量都是整数。
【问题讨论】:
标签: python python-3.x