-1
supposing I have x students who have had x notes. how do I put the name of the student who had the best grade?
# coding: iso-8859-1 -*-
import math
nAlunos=0
while True:
    nAlunos=eval(input('Indique o número de alunos:'))
    if 1<=nAlunos<=100:
        break
    else:
        print('O número de alunos tem de ser entre 1 e 100')
        print()
ListaNomes=[0 for i in range(0,nAlunos)]
ListaNotas=[0 for i in range(0,nAlunos)]
reprovados=0
suficiente=0
bom=0
muitobom=0
for i in range(0,nAlunos):
    ListaNomes[i]=input('Nome:')
    while True:
        ListaNotas[i]=eval(input('Nota:'))
        if 0<=ListaNotas[i]<=20:
            if 0<=ListaNotas[i]<10:
                reprovados=reprovados+1
            elif 10<=ListaNotas[i]<14:
                suficiente=suficiente+1
            elif 14<=ListaNotas[i]<17:
                bom=bom+1
            elif 17<=ListaNotas[i]<20:
                muitobom=muitobom+1
            break
        else:
            print('A nota tem de estar entre 0 e 20')
            print() 
PercentagemReprovados=(reprovados*100)/len(ListaNotas)
PercentagemSuficiente=(suficiente*100)/len(ListaNotas)
PercentagemBom=(bom*100)/len(ListaNotas)
PercentagemMuitobom=(muitobom*100)/len(ListaNotas)
print()
for i in range(0,nAlunos):
    print(ListaNomes[i])
    print(ListaNotas[i])
print()
print(PercentagemReprovados)
print()
print(PercentagemSuficiente)
print(PercentagemBom)
print(PercentagemMuitobom)
print()
print(max(ListaNotas))
for i in max(ListaNotas[i]):
    print(ListaNomes[i])
    
the last line is giving me error and I’m not realizing how I should add the name of the student who had the highest grade
If you had two students the same grade should appear the two who had the best grade, I do not know if it is possible to appear all the students who had the best but if you can help me thank
– Diogo
I added what to do to have all students with the best grade
– Flavio Moraes
can you see the result without appearing between [ ]? for example now appears ['Tiago','Ruben'] ... you can only see Tiago , Ruben ?
– Diogo
gives yes, you can do
print(str(melhores)[1:-1])orprint(", ".join(melhores)). In the first the names appear in quotes and in the second not– Flavio Moraes