question: Using the text file notas_estudantes.dat write a program that calculates the minimum and maximum grade of each student and print the name of each student along with its maximum and minimum mark. file:
jose 10 15 20 30 40
pedro 23 16 19 22
suzana 8 22 17 14 32 17 24 21 2 9 11 17
gisela 12 28 21 45 26 10
joao 14 32 25 16 89
My code:
arq=open('notas_estudantes.dat','r')
conteudo=arq.readlines()
arq.close()
for item in conteudo:
lista=item.split()
lista.sort()
print(lista[-1],':','Nota Maxima:',lista[-2],'Nota Minima:',lista[0])
When I go to print give this:
jose : Nota Maxima: 40 Nota Minima: 10
pedro : Nota Maxima: 23 Nota Minima: 16
suzana : Nota Maxima: 9 Nota Minima: 11
gisela : Nota Maxima: 45 Nota Minima: 10
joao : Nota Maxima: 89 Nota Minima: 14
the others are all correct but when the part of suzana arrives it does not give the correct result, I would like to know if it is something pyhton error or it was myself that I did something wrong in the code.