Hello. I am a python noob asking a probably obvious question. I am making sort of a question game, although its still in the debugging stage. The problem is below. (Way below)
#A simple game of common knowledge.
#Dependecies
import time
start = ""
lv1 = False
lv2 = False
lv3 = False
choicey = False
choicen = False
lvRule = True
ynRule = True
lives = 3
points = 0
print "Would you like to play the question game?"
playgame = raw_input("y/n? ")
if playgame == "y":
start = True
#Choosing a level
while start == True:
LVup = False
print "Select a level"
Next = True
if Next == True:
level = raw_input("1, 2, or 3 ")
if level == "1":
lv1 = True
if level == "2":
lv2 = True
if level == "3":
lv3 = True
#List of correct answers
y1a = "Yes"
y1b = ""
y1c = ""
y2a = ""
y2b = ""
y2c = ""
y3a = ""
y3b = ""
y3c = ""
n1a = "Yes"
n1b = ""
n1c = ""
n2a = ""
n2b = ""
n2c = ""
n3a = ""
n3b = ""
n3c = ""
#The questions, picked randomly.
woo = ("y", "n")
from random import choice
print choice(woo)
if choice(woo) == "y":
choicey = True
if choice(woo) == "n":
choicen = True
while choicey == True:
if lv1 == True:
ywoo = ("Is this Working?", "Is this Working?")
if lv2 == True:
ywoo = ("")
if lv3 == True:
ywoo = ('PUT QUESTIONS HERE')
print choice(ywoo)
#Defining the correct answer, if the answer is no.
if ywoo == ("Is this Working?" and lv1 == True):
CorrAns = y1a
if ywoo == ("" and lv1 == True):
CorrAns = y1b
if ywoo == ("" and lv1 == True):
CorrAns = y1c
if ywoo == ("" and lv2 == True):
CorrAns = y2a
if ywoo == ("" and lv2 == True):
CorrAns = y2b
if ywoo == ("" and lv2 == True):
CorrAns = y2c
if ywoo == ("" and lv3 == True):
CorrAns = y3a
if ywoo == ("" and lv3 == True):
CorrAns = y3b
if ywoo == ("" and lv3 == True):
CorrAns = y3c
AnsIsYesLoop = True
while AnsIsYesLoop == True:
AnswerY = raw_input("y/n? ")
if AnswerY != ("n", "y"):
BadAns = True
if AnswerN == "n":
GoodAns = True
if AnswerN == "y":
WrongAns = True
while BadAns == True:
print "Please answer 'y' or 'n'."
AnsYesLoop = True
while choicen == True:
if lv1 == True:
nwoo = ('PUT QUESTIONS HERE')
if lv2 == True:
nwoo = ("Is Obama's running mate John Biden?")
if lv3 == True:
nwoo = ('PUT QUESTIONS HERE')
print choice(nwoo)
#Defining the correct answer, if the answer is no.
if nwoo == ("Is this Working?" and lv1 == True):
CorrAns = n1a
if nwoo == ("" and lv1 == True):
CorrAns = n1b
if nwoo == ("" and lv1 == True):
CorrAns = n1c
if nwoo == ("" and lv2 == True):
CorrAns = n2a
if nwoo == ("" and lv2 == True):
CorrAns = n2b
if nwoo == ("" and lv2 == True):
CorrAns = n2c
if nwoo == ("" and lv3 == True):
CorrAns = n3a
if nwoo == ("" and lv3 == True):
CorrAns = n3b
if nwoo == ("" and lv3 == True):
CorrAns = n3c
AnsIsNoLoop = True
while AnsIsNoLoop == True:
AnswerN = raw_input("y/n? ")
if AnswerN != ("n", "y"):
BadAns = True
while BadAns == True:
print "Please answer 'y' or 'n'."
AnsNoLoop = True
if AnswerN == "n":
GoodAns = True
if AnswerN == "y":
WrongAns = True
if Uwin == True:
BadAns = False
GoodAns = False
Next = False
print "You win!"
if level == ("1", "2"):
print "Would you like to move to the next level? y/n?"
NextLV = raw_input()
if NextLV == "y":
LVup = True
while LVup == True:
if level == ("1", Next == False):
level = "2"
lv1 = False
Next = True
Start = True
if level == ("2", Next == False):
level = "3"
lv2 = False
Next = True
start = True
if level == ("3"):
start = False
if GoodAns == True:
BadAns = False
points = points + 1
print "The correct answer is;"
print CorrAns
print "You are correct! You now have", points, "points."
print "Only", 3 - points, "to go!"
if points == 3:
Uwin = True
if WrongAns == True:
lives = 1 - lives
BadAns = False
Next = False
print "The correct answer is;"
print CorrAns
if lives > 1:
print "You have", lives, "lives left."
if lives == 1:
print "You have", lives, "life left."
if lives == 0:
GameOver = True
while GameOver == True:
print "Game over!"
print "Would you like to play again?"
PlayAgainLoop = True
while PlayAgainLoop == True:
PlayAgain = raw_input("y/n?" )
if PlayAgain == "y":
start = True
if PlayAgain == "n":
break
if PlayAgain != ("n", "y"):
print "Please answer y/n"
PlayAgainLoop = True
if playgame == "n":
start = False
while start == False:
print "See ya!"
time.sleep(1.5)
break
I have my problem here;
AnsIsNoLoop = True
while AnsIsNoLoop == True:
AnswerN = raw_input("y/n? ")
if AnswerN != ("n", "y"):
BadAns = True
while BadAns == True:
print "Please answer 'y' or 'n'."
AnsNoLoop = True
if AnswerN == "n":
GoodAns = True
if AnswerN == "y":
WrongAns = True
When I answer y/n it treats it as if I answered somthing else, hence this line.
if AnswerN != ("n", "y"):
BadAns = True
And when I enter somthing random like fadshbfbhsf it simply repeats the question.
All help is apperciated.