mercredi 6 mai 2020

How to use if, elif and else statement?

I am a beginner to programming(only 9 days).

I recently learned if, else statements. But I am facing a problem when applying it.

When I use code

    y=input('ans>>')
    if y=='c':
        q=5
    elif y=='a'or'b'or'd':
        q=-1
    else:
        q=0
    print(q)

when I input c it gives me 5, when i input a it gives me -1 but

when I input no other than a,b,c,d it still gives me -1 every time but it is suppose to give 0

how do I fix this?

Aucun commentaire:

Enregistrer un commentaire