A better explanation on CONDITIONALS

--Originally published at Nihilistic Kirby

The “>>>if” conditional is the easiest one, it just focuses on creating an event ‘if’ some specific event takes place before.

food = 'spam'

if food == 'spam':
    print('Ummmm, my favorite!')
    print('I feel like saying it 100 times...')
    print(100 * (food + '! '))

The “>>>elif” is a combination of the commands “else” and “if”, which works exactly just like the “if”, but this one is closely related to the initial conditional; however, this type of conditional is more relevant in loops that can break, such as “while” loops.

if x < y:
    STATEMENTS_A
else:
    if x > y:
        STATEMENTS_B
    else:
        STATEMENTS_C

The “>>>else” is not exactly a conditional, as it only works for all the events that could happen if the first event is not correct or what it is expected to be.

if choice == 'a':
    print("You chose 'a'.")
elif choice == 'b':
    print("You chose 'b'.")
elif choice == 'c':
    print("You chose 'c'.")
else:
    print("Invalid choice.")

Is important to know that the “if” can be all by its own and will still work, but the other two need to have an “if” that can lead them.