在Python中允许使用大写“是”输入和非大写“是”输入或值的正确方法是什么?

问题描述 投票:-1回答:1

'''我试图允许用户输入一个大写的“是”作为输入,或者输入一个非大写的“是”作为输入,并且仍然获得变量的“真”值,与“电话”或“电话”相同且相同为变量,援助。

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.')

'''

python-3.x input
1个回答
0
投票

尝试这样的事情:

x = input('...')
if(x == 'Yes' or x == 'yes'):
    print('True')
else:
    print('False')
© www.soinside.com 2019 - 2024. All rights reserved.