I am in the process of making a simple guessing game and have run into a few problems. Firstly I am new to Python and this is my first programming language besides some batch.
When I try to execute the following code, the elif
and the else
do not get interacted with, even when the condition is true. It seems to always respond to the if
like it is always true.
#Calder Hutchins 3-1-14
#Guess Game
import time
playGame = ""
guessTry = 3
print "Would you like to play a game? (y/n)"
while playGame != "y":
playGame = raw_input(">")
if playGame == "y" or "n":
print "Great! Let's get started!"
print "Answer the following questions correctly to level up!"
elif playGame == "n":
print "Very well...."
time.sleep(2)
quit()
else:
print "Invalid answer, please re-type."
print "end of the while, test."
Also I was wondering about flow control since it is new to me. Is there a way to make it more efficient, the code I pasted.
EDIT: this is not a duplicate... if some of you would of taken the time to actually look at my question you would see it is not. I find it very disappointing to see this happen so many times on Stack Overflow.