[英]I am trying to make a quiz app in python and want to display the question and options separately can someone help me?
[英]I am trying to make a simple quiz in python but everything returns False?
我输入的每个答案都返回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
更改if answer == 'a':
改为if answer == 'a' or answer == 'A':
或者,按照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
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.