0
coffeortea = input("Would you like coffee or tea? ")
if 'coffee' == coffeortea:
    print("1")
elif 'c' == coffeortea:
    print("2")
else:
    print("3")

I would like it if the user types coFfeE to print 1. or if the user types C to type 2. Basically, I want upper and lower case to not be an issue.

John Kugelman
  • 349,597
  • 67
  • 533
  • 578

2 Answers2

2

Compare on the if clauses everything uppercase or lowercase

coffeortea = input("Would you like coffee or tea? ")
if 'coffee' == coffeortea.lower():
    print("1")
elif 'c' == coffeortea.lower():
    print("2")
else:
    print("3")
Abe
  • 1,357
  • 13
  • 31
francisco sollima
  • 7,952
  • 4
  • 22
  • 38
0

You can receive your input with properly convertion to str, with lower() function call, and then, make your condition basing on that:

coffeortea = str(raw_input("Would you like coffee or tea? ")).lower()
if 'coffee' == coffeortea:
    print("1")
elif 'c' == coffeortea:
    print("2")
else:
    print("3")
Abe
  • 1,357
  • 13
  • 31