-1
Good afternoon, I’m inputando numbers in python, but I don’t know how to add them to a set and then make python decide which is the largest number in the list.
Grateful
-1
Good afternoon, I’m inputando numbers in python, but I don’t know how to add them to a set and then make python decide which is the largest number in the list.
Grateful
6
Taking into account 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))
Thanks, but I forgot to tell you that since it’s college exercise, I can’t use it for pq we haven’t learned yet haha
Just change po while, like you did in the example.
I get it, thank you
I made a new version, I’ll edit the answer
0
I’m starting now in python, but I realized that the while loop would be correct if it was 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))*
I’m sorry if I mentioned anything wrong.
When posting an answer, you should do it with conviction (even if you’re wrong). Answers like "try", "I think", "maybe", "may be" are not concrete answers and are subject to being excluded or gain negative votes.
ok thanks for the tip.
0
lista = []
while len(lista) < 5:
lista.append(input("Digite 5 numeros: "))
print "Maior numero: ", max(lista)
-1
lista = []
while len(lista) < 5:
n = int(input('Digite o número (0 para encerrar): '))
lista.append(n)
print ('O maior número da lista é: ',max(lista))
Browser other questions tagged python python-3.x
You are not signed in. Login or sign up in order to post.
Hi Welcome, show how you are doing, have any part of the code ? so we can help you better...
– ederwander
I’m going to write a code as an example, so it’s easier people = 5 answers = 0 while answers < people: age = int(input("Enter the person’s age") after that, I wanted to save each age inputada in a set and then print the largest of them, but I don’t know how.
– Rodrigo Costa
Look at my answer. I think that’s exactly what.
– Sidon
the number of numbers entered is predefined?
– Math