-2
In a long jump competition each athlete is entitled to five jumps. The result of the athlete will be determined by the average of the five remaining values. You must make a program that receives the name and the five distances reached by the athlete in his jumps and then enter the name, the jumps and the average of the jumps. The program must be closed when the name of the athlete is not given.
You’re making a mistake on this line
print(nsaltos[j],todosaltos[i[j]]," m")
builtins.Typeerror: 'int' Object is not subscriptable
nsaltos = ['Primeiro Salto: ','Segundo Salto: ','Terceiro Salto:
','Quarto Salto: ','Quinto Salto: ']
atletas = []
saltos = []
todosaltos = []
nome = 0
media = 0
lstsalto = ""
while True:
nome = str(input("Digite o nome: "))
atletas.append(nome)
if nome == '':
break
for i in range(5):
distancia = float(input("Digite a distancia %d: "%(i+1)))
saltos.append(distancia)
todosaltos.append(saltos)
saltos = []
atletas.pop(len(atletas)-1)
for i in range(len(atletas)):
print("Atleta: ",atletas[i])
print("")
for j in range(len(todosaltos[i])):
print(nsaltos[j],todosaltos[i[j]]," m")
media += todosaltos[i[j]]
convsalto = str(todosaltos[i[j]])+" -"
lstsalto += convsalto
print("Resultado final:")
print("Atleta: ",atletas[i])
print("Saltos: ",lstsalto)
print("Média dos saltos: ",(media/5)," m")
media = 0
lstsalto = ""
You’re trying to access the position
j
of an integer numberi
when it does[i[j]]
. I believe what you intend to do is[i][j]
, using separate brackets. Other than that, I believe it is possible to greatly improve the code.– Woss
Again I ask silly mistake here, I swear I research before I ask, but I found nd. How could I improve the code? I’m dumb in programming
– Ph13