-1
How do I find the largest number read and the smallest number read?
I tried the max
and the min
and it didn’t work.
arquivo = open('notas_alunos.txt', 'r')
lista_notas = []
conteudo = arquivo.readline()
linha = conteudo[:-1].split(';')
lista_notas.append(linha)
while conteudo:
conteudo = arquivo.readline()
linha = conteudo[:-1].split(';')
lista_notas.append(linha)
arquivo.close()
lista_notas.pop()
for elemento in range(0, len(lista_notas)):
matricula = lista_notas[elemento][0]
nota_1 = float(lista_notas[elemento][1])
nota_2 = float(lista_notas[elemento][2])
nota_3 = float(lista_notas[elemento][3])
nota_4 = float(lista_notas[elemento][4])
media = (nota_1 + nota_2 + nota_3 + nota_4)/4
print('{0} {1:.2f} {2:.2f} {2:.2f} {3:.2f} {4:.2f}'.format(matricula,nota_1,nota_2,nota_3,nota_4,media))
Always search the official documentation. See the topic on data structure: https://docs.python.org/2/tutorial/datastructures.html and note that lists do not contain "max" and "min". You can sort with "Sort", for example: list.Sort() and the Boolean parameter "Reverse" will define whether the sort will be ascending or descending and you can also define a key for your sort, for example: list.Sort(Reverse=True, key=orderSame) or list.Sort(Reverse=True, key=lambda value: value['value'])
– leogregianin