-1

Considering the following construct that controls strings:

if input_ == "Option1":
    print "Option 1"
elif input_ == "Option2":
    print "Option 2"
else:
    print "Option x"

Is there any way to make Option1 and Option2 to accept any capitalized characters (such as "option1", "OpTion1", "OPTION1" etc...)?

Barmar
  • 741,623
  • 53
  • 500
  • 612
IanWing
  • 113
  • 9

1 Answers1

3

convert the input to a single case, then compare that.

input_ = input_.lower()
if input_ == "option1":
    print "Option 1"
elif input_ == "option2":
    print "Option 2"
else:
    print "Option x"
Barmar
  • 741,623
  • 53
  • 500
  • 612