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
  • 330,190
  • 66
  • 504
  • 555

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,207
  • 12
  • 30
francisco sollima
  • 7,352
  • 3
  • 21
  • 37
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,207
  • 12
  • 30