我输入的每个答案都返回False;甚至A.有人可以帮助我。
def space():
print' '
print 'Welcome to the quiz'
space()
print 'Chose the correct answer'
space()
print 'Who am I? '
space()
print "A. Zachary "
print "B. Max"
print "C. Nick"
print "D. All of the above"
print 'type in the correct answer'
answer = raw_input()
if answer == 'a':
print True
else:
print False
答案 0 :(得分:1)
将if answer == 'a':
更改为if answer == 'a' or answer == 'A':
或,根据the suggestion of Paul Rooney,您可以使用if answer.lower() == 'a':
。
此外,在def space():
中,print ' '
应缩进。
def space():
print ' '
print 'Welcome to the quiz!'
space()
print 'Chose the correct answer.'
space()
print 'Who am I? '
space()
print "A. Zachary "
print "B. Max"
print "C. Nick"
print "D. All of the above"
print 'Type in the correct answer.'
answer = raw_input()
if answer == 'a' or answer == 'A':
print True
else:
print False
键入A
或a
会产生True
。