【发布时间】:2023-01-24 02:16:06
【问题描述】:
我正在尝试制作问答游戏,但如果我回答正确,它会给我错误的答案,是否区分大小写?
代码 :
score = 0
question_n = 0
playing = input('Do you wish to start? (Yes-No)')
if playing == "yes" or playing == "y":
question_n +=1
ques = input(f'\n{question_n}. Who owns amazon? ')
if ques == 'Jeff bezos':
print('Correct! You got 1 point.')
score +=1
print(f'Your score is : {score}')
else:
print('Incorrect')
print(f'The correct answer is --> Jeff bezos. ')
x = input('Press any key to exit..')
elif playing == "no" or playing == "n":
print('Thanks for trying me (:')
错误 :
Do you wish to start? (Yes-No)yes
1. Who owns amazon? jeff bezos
Incorrect
The correct answer is --> Jeff bezos.
Press any key to exit..
【问题讨论】:
-
这似乎不是
tkinter问题 -
是的,它区分大小写。取一些字符串
s = 'jEfF bEzOs'并设置s = s.title()将通过将字符串中每个单词的首字母大写来设置s = 'Jeff Bezos'。