[Python] Trying to to a follow up question on python but it keeps running the right ones back...

Discussão em 'Python' iniciado por Stack, Março 10, 2025.

  1. Stack

    Stack Membro Participativo

    I wanted to just play around with some variables and got stuck on this problem where everytime I input the wrong answer to my variable, it runs back to the first question instead of continuing from where it was.

    How can I solve this?

    while True:
    dia = float(input("Insira o dia do mês: "))
    if dia > 31:
    print("O dia informado é um número inválido!")
    continue
    mes = float(input("Digite o mês do ano: "))
    if mes > 12:
    print("O mês informado é um número inválido!")
    continue
    ano = float(input("Insira o ano atual: "))
    if ano > 2025:
    print("O ano informado é um número inválido!")
    continue
    break
    print(f"A data de hoje é: {dia:.0f}/{mes:.0f}/{ano:.0f}.")

    Continue reading...

Compartilhe esta Página