Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Python
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 = "Good Internet Speed"
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 $",score
Posted
Updated 9-Nov-14 1:29am
v2
Comments
OriginalGriff 7-Nov-14 4:49am    
How would we know?
We have no idea what it is meant to do, much less what it is doing that is not what you expected!

Use the "Improve question" widget to edit your question and provide better information.
Richard MacCutchan 9-Nov-14 7:30am    
You have not used indenting so Python will not understand where your blocks start and end (a pretty stupid language IMHO).

1 solution

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):
Python
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,)
 
Share this answer
 
Comments
Maciej Los 9-Nov-14 16:40pm    
+5
Thomas Daniels 10-Nov-14 4:39am    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900