2
Hello, good afternoon everyone. I am a student in Python language and I am having difficulties in an exercise.
I developed the code that returns me a list with my numbers entered in the list, but I can’t count how many times the number 5 was typed. Would someone please help me?
numeros = []
cont = 0
while True:
num = input('Digite um número: ')
while not num.isnumeric():
print('Opção inválida')
num = input('Digite um número: ')
else:
numeros += num
cont += 1
esc = input('Deseja continuar?[S/N]: ')
while not esc.isalpha():
print('Opção inválida.')
esc = input('Deseja continuar?[S/N]: ')
else:
if esc in 'Ss':
print('', end='')
elif esc in 'Nn':
break
else:
print('Por favor, use apenas S ou s, N ou n, tente novamente.')
esc = input('Deseja continuar?[S/N]: ')
print(numeros)
print(numeros.count(5))
If the code appears a bit messy here because of the formatting of the site that I do not yet master, forgive me.
I am very happy by the response of each one so far, is of great value what they do on this site. Now I can continue my studies without having to skip this exercise and better understand the logic of the promise in python.
– Jean Flordemiro