-4
I would like to know if there is any module, function, etc. that would allow me to go back to a certain line of code.
I have this doubt because, whenever I want to ask a question repeatedly, I have to put the same variable again, as in lines 7 and 12
tupla = 'zero', 'um', 'dois', 'três', 'quatro', 'cinco', 'seis', 'sete', 'oito', 'nove', 'dez', 'onze',\
'doze', 'treze', 'quatorze', 'quinze', 'dezesseis', 'dezessete', 'dezoito', 'dezenove', 'vinte'
for num in tupla:
num = int(input('Digite um número: '))
ext = tupla[num]
print(f'Você digitou o número {ext}')
opcao = str(input('Quer continuar a ler os números por extenso? [S/N] ')).upper().strip()
while opcao == 'S':
num = int(input('Então digita outro número: '))
ext = tupla[num]
print(f'Você digitou o número {ext}')
opcao = str(input('Quer continuar a ler os números por extenso? [S/N] ')).upper().strip()
while opcao == 'N':
exit('Obrigado por usar nosso programa.')
I don’t understand the question, you already use a loop of repetition while in your code. See Why in Python there is no drop?
– Augusto Vasques
The question I have is if there’s anything that makes me not need to replicate the question in the code.
– Igor Araújo
So I’m going to rephrase. Why do you ask about repeating structures if you already use repeating structures in your code?
– Augusto Vasques
I think I have already understood why there is no way to refer to a certain line of code with the link you gave me about the fact that there is no goto in Python. However, just to be clear, what I wanted to know is if there was a way to not need to replicate, even if it is within a repeat structure, the same line of code.
– Igor Araújo