Can anyone help me with this code? I have two problems: The first is the error mentioned in the title and the second is the function vector, which does not receive assignment (when I was debugging in the compiler, I realized that U was not receiving any values). I'm new to programming, do not be surprised if there's some barbaric error;)
def calPercent(nvJ,tV):
U = [0]*23
for i in range(23):
if nvJ[i]!= 0:
U[i] = nvJ[i]/tV*100
return U
V = [0]*23
P = [0]*23
voto = int(input("Numero do jogador (0=fim): "))
while voto!=0 :
if voto<1 or voto>23 :
print "Informe um valor entre 1 e 23 ou 0 para sair!"
else:
V[voto-1]+=1
voto = int(input("Numero do jogador (0=fim): "))
P = calPercent(V,sum(V))
print "Foram computados",sum(V),"votos"
print "Jogador,Votos,%"
for i in range(23):
if V[i]!=0 :
print "%d,%d,%d%" %(i+1,V[i],P[i])
for i in range(23):
if V[i] == max(V):
print "O melhor jogador foi o numero %d, com %d votos, correspondendo a %d% do total de votos" %(i+1,V[i],P[i])