-1
Talk to the guys! If anyone can help me?
When he asks me if I want to continue and I press enter without typing anything he lets me proceed. I wish that when I hit enter without typing anything it won’t let me continue, only if I type 'Ss' or 'Nn'. How do I handle this blank string? Thanks...
soma = media = cont = 0
maior = menor = 0
r = 'Ss'
while r != 'Nn':
while True:
try:
n = float(input('Digite um número inteiro: '))
break
except ValueError:
print('Entrada Inválida!')
soma += n
cont += 1
if cont == 1:
maior = n
menor = n
if n > maior:
maior = n
elif n < menor:
menor = n
r = str(input('Quer continuar? S/N? ')).strip()
while r not in 'Ss' and r not in 'Nn':
r = str(input('Quer continuar? S/N?' ')).strip()
if r not in 'Ss':
r = 'Nn'
media = soma / cont
print('\033[36m<=>\033[m'*10)
print('Foram digitados \033[32m{}\033[m números e a \033[32mmédia\033[m entre eles foi de \033[32m{:.2f}\033[m.'.format(cont, media))
print('O \033[32mmaior\033[m número digitado foi \033[32m{}\033[m.'.format(maior))
print('O \033[32mmenor\033[m número digitado foi \033[32m{}\033[m.'.format(menor))
while r not in 'Ss' and r not in 'Nn':
realize that it is an and, not an or– FourZeroFive
Thanks. The point is that when I don’t digitize anything it proceeded with the code. I’d like to treat that. I’ve used the or else it stays inside the loop forever. The question here is to treat the string in white, otherwise I’m wrong.
– Myckel Anderson