-2

''' I am trying to allow a user to type a capital "Yes" as input or a non-capitalized "yes" as input and still get a 'True' value for the variables, good and the same with 'phone' or 'Phone' for the variable, aid.

print ('Do you want to take the Carona Test in North Carolina: Type in 
"Yes or No"')
    good='Yes' 
    aid='phone'
    good = input()
    if good == 'Yes':
      print ('The address is 1801 Glendale Dr SW, Wilson, NC 27893. ' + 
      'If you need the Helpline, type "phone" and if not type in "No".')
      aid = input()
      if aid=='phone':
              print("NC CDC Help Line 1-866-462-3821. Don't forget to wash 
your hands.")
      else:
          print('You have elected to do nothing silly human scum, good luck.')

'''

  • rather https://stackoverflow.com/questions/319426/how-do-i-do-a-case-insensitive-string-comparison – mkrieger1 Apr 29 '20 at 21:43
  • This answer had to do with the output from a print function. ( and the it still give you the right output and not the error handling message) I am interested in how to let a user type in a value such as Yes or YeS and have it act as "Yes" or to be "case insensitive" to engage a print function. My printed content is as is and does not need to be corected – Peter Cockram Apr 29 '20 at 22:15

2 Answers2

0

Try something like this:

x = input('...')
if(x == 'Yes' or x == 'yes'):
    print('True')
else:
    print('False')
Connor
  • 272
  • 1
  • 2
  • 10
  • This was the answer: if (good == 'Yes' or good == 'yes'): Thank you, Connor, good work! – Peter Cockram Apr 29 '20 at 22:19
  • I thank conner for the answer - He nailed it. But Im curious now about making the same request - but to solve the problem of a user being case insensitive, YeS, YES, yEs... – Peter Cockram Apr 29 '20 at 22:26
0

For a completely case insensitive solution, cast the user input to lower or upper case.

if input('Do you want the Coronavirus test in NC?').lower() == 'yes':
    print('Instructions here')
else:
    print('Okay')
Steven Brown
  • 365
  • 3
  • 8