-1
Write a program that reads multiple integers until a negative number is typed. The program has to return the smallest and largest number read.
I tried to do, but when it comes to show the smallest number read is always showing the 0.
maior = menor = valor = i = 0
print('Digite números inteiros! Um número menor que zero para o programa!')
while valor >= 0:
valor = int(input(f'Digite o {i + 1}° valor: '))
if valor > maior:
maior = valor
if (valor < menor) and (valor >= 0):
menor = valor
i += 1
print(maior)
print(menor)
If the value has to be >= 0 and you set it to zero initial value then no value reported will be less than this initial value. Try to put as many as possible to be represented on this type of data.
– anonimo