Zachary Walsh
Zachary Walsh

Reputation: 1

I am trying to make a simple quiz in python but everything returns False?

Every answer I put in returns False; even A. Can someone please help me.

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

Upvotes: 0

Views: 63

Answers (1)

JP Maulion
JP Maulion

Reputation: 2504

Change if answer == 'a': to if answer == 'a' or answer == 'A': OR, as per the suggestion of Paul Rooney, you can use if answer.lower() == 'a':.

Also, in def space():, print ' ' should be indented.

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

Typing A or a yields True.

Upvotes: 1

Related Questions