Python3 Ex29: If-Statements

I know that dogs += 5 means dogs = dogs + 5.** Initially, you gave the variable dogs a value of 15 . So when you add 5 , the new stored value is 20 . So now dogs = 20 .

I thought that as the program ran down the if-statements, that if would run the one that would be true. The only If-statement that I thought was true was if people == dogs since people was initialized as 20 and the new value for dogs is also 20. So shouldn’t “People are dogs.” only print?

Please clarify my misconception. What am I not understanding clearly?

HERE IS THE CODE

people = 20
cats = 30
dogs = 15

if people < cats:
    print("Too many cats! The world is doomed!")

if people > cats:
    print("Not many cats! The world is saved!")

if people < dogs:
    print("The world is drooled on!")

if people > dogs:
    print("The world is dry!")

dogs += 5

if people >= dogs:
    print("People are greater than or equal to dogs.")

if people <= dogs:
    print("People are less than or equl to dogs.")

if people == dogs:
    print("People are dogs.")

HERE IS MY OUTPUT FROM TERMINAL
Too many cats! The world is doomed!

The world is dry!

People are greater than or equal to dogs.

People are less than or equl to dogs.

People are dogs.

Welcome to the forum @Ren.

Have you seen it yet?
I am asking because sometimes when I post something in here I see it my self after a while.
When you got some distance to the problem you can see it with a fresh mind.

The answer is in the print statement.
”greater or equal” (>=) is true.
”less or equal (<=) is also true.
”People are dogs” (==) is very much true (20==20).

I hope this clearify a little.

Thank you, ulfen69! I see why all 3 if-statements printed out. I forgot the truth table values of ‘or’ logic. False or True is True.

I replied to you on email a little more elaborately, but reading this I realize I can just say:

You want to read about the else and elif keywords. Otherwise all if-statements are not connected and run separately. With else you get what you want, and elif combines the two. Try it.