[Python] Why is Python not evaluating this Boolean condition? [duplicate]

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

  1. Stack

    Stack Membro Participativo

    If I run this example code:

    age = int(input("Enter age:\n"))

    if age < 100:
    birthday = bool(int(input("Is it your birthday? (Enter 1 or 0):\n")))

    if age == 5 or (age == 3 and birthday):
    print("Yes")
    else:
    print("No")


    and I enter 150 for age, it outputs "No".

    This means that if age == 5 or (age == 3 and birthday): is not being evaluated, since it would return an error if it were, because birthday exists only if age is under 100. Why is this?

    Continue reading...

Compartilhe esta Página