Good afternoon, I'm inputting numbers in python, but I do not know how to do it to aggregate them to a set and then have python decide which is the largest number in the list.
Thankful
Good afternoon, I'm inputting numbers in python, but I do not know how to do it to aggregate them to a set and then have python decide which is the largest number in the list.
Thankful
Considering only integers (you can adapt to other types):
Version with for:
lista = []
qtn = input('informe a qt de numeros: ')
for n in range(0,int(qtn)):
lista.append(int(input('Digite o número: ')))
print ('Maior número da lista: ', max(lista))
Version with while:
lista = []
while True:
n = int(input('Digite o número (0 para encerrar): '))
if n == 0:
break
lista.append(n)
print ('O maior número da lista é: ',max(lista))
I'm starting now in python, but I realized that the while loop would be correct if it were written like this:
lista = [] while True: n = int(input('Digite o número (0 para encerrar): ')) lista.append(n) if n == 0: break print ('O maior número da lista é: ',max(lista))*
Sorry if I mentioned anything wrong.