There are some problems here:
- At line 20, you wrote
playeranswer == raw_input("answer: ")
but that's an assignment, so you just have to use one =
sign here. print "well done! your score is now $",score
doesn't work fine for me, try print "well done! your score is now %i" % (score,)
.- In your code, you wrote
answer = "Good Internet Speed"
but you want the user to post one letter as answer, so use answer = "a"
- Your indentation is incorrect. Python requires indentation of each code block.
- Your code also won't work perfectly if you just have two questions.
Code with the problems corrected (aside from the "not enough questions" problem):
score = 1
count = 0
while score != 1024:
count = count+1
if score == 1024:
print "you win!"
if count == 1:
print "What does Mr West not have?"
print "a Good Internet Speed"
print "b Glasses"
print "c A Computer"
playeranswer = raw_input("answer: ")
answer = "a"
elif count == 2:
print "What is the meaning of life?"
print "a 69"
print "b 34"
print "c 42"
playeranswer = raw_input("answer: ")
answer = "c"
else:
print score
if playeranswer == answer:
score = score*2
print "well done! your score is now %i" % (score,)