dimanche 29 mars 2020

Python3: If and else are running fine but when I add elif there is no output

I'm trying to run a simple if, elif and else statements. My code is:

def main():
    x, y = 100, 100


    if (x < y):
        st = "x is less than y"
    elif (x == y):
        st = "x is the same as y"
    else:
        st = "x is greater than y"

    print(st)

I started with just if and else, and I got "x is greater than y". Obviously, it's not correct so I added an elif statement to get "x is the same as y". However, when I run the above code, there is no output. It doesn't come up with error, just blank.

Can someone explain to me why is it so or what I am doing wrong?

Aucun commentaire:

Enregistrer un commentaire