Create a program where the user can type multiple numeric values and sign them into a list. If the number already exists inside, it will not be added. At the end, all the unique values entered will appear in ascending order.
And so far so good, that was my solution:
lista= []
while True:
ad = (int(input('Digite um valor: ')))
if ad not in lista:
lista.append(ad)
print('Adicionado com sucesso!')
else:
print('Valor duplicado. Adição negada.')
ask = str(input('Deseja continuar?[S/N] ')).strip().upper()[0]
while ask not in 'SN':
if ask == 'S':
continue
elif ask == 'N':
break
elif ask != 'SN':
print('Resposta inválida, por favor escolha entre [S/N]')
while ask not in 'SN':
ask = str(input('Deseja continuar?[S/N] ')).strip().upper()[0]
print('-=' * 30)
lista.sort()
print(f'Voce digitou os números: {lista}')
When asked if I want to continue and I say 'N', the program will still work without giving break
. However the same code in another colleague's PyCharm works with no problem at all.
What can this be? A bug ? Is it possible to resolve it?