[Python] If statement does something weird [duplicate]

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

  1. Stack

    Stack Membro Participativo

    Can someone please explain why it doesn't print "Hi", but instead prints "bye"?

    a = 5
    b = -5

    if b > 0 != a > 0:
    print("Hi")
    else:
    print("Bye")


    Changing it from "!=" to "and not" doesn't help. Thank you in advance.

    I asked chatgpt, it basically told me that it doesn't know why it happens.

    Continue reading...

Compartilhe esta Página