mercredi 8 août 2018

The if-statement is triggered no matter the input [duplicate]

This question already has an answer here:

I'm trying to code some kind of multiple-choice kinda game, but no matter the input, the if-statement is always triggered, even if the input is d or D.

It might be an obvious mistake, but I'm an absolute beginner at programming, so I really hope you guys can help me point out what I've done wrong.

My code looks like this:

answer = input("Do you want to do something (C) or something else (D)? [C/D]")

if answer == "c" or "C":
    print ("You typed", answer)
    time.sleep(2)
    print ("You can now do something")
    time.sleep(2)


elif answer == "d" or "D":
    print ("You typed", answer)
    time.sleep(2)
    print ("You can now do something else")
    time.sleep(2)


else:
    Exit()

Aucun commentaire:

Enregistrer un commentaire