I am using Python 2.7. The program generates a random number and asks the user to guess what it is. The while statements work good. The conditional if statement ends the program without following instructions of print followed by calling the function to see if the user wants to play again.
What makes an if statement not follow instructions? Is there a conflict with the later while statements?
# generate random number between 1 & 9
# have user guess the number, then
# tell them if they guessed too low,
# too high, or exactly right
# keep the game going until user types "exit"
# track how many guesses the user has taken, and when game ends, print it out
import random
a = random.randint(1, 9)
#def whatUp():
#print ("You got it correct")
def playAgain():
wieder = input("Do you wish to play again? Y or N ")
if wieder == "Y":
guessThis()
elif wieder == "N":
print ("Have a day")
elif wieder != "Y" or "N":
wieder = input("Do you wish to play again? Y or N ")
def guessThis():
#a = random.randint(1, 9)
findout = int(input("Enter a number from 1 to 9 "))
i = 1
if findout == a:
#whatUp()
print ("You got it correct")
playAgain()
while findout > a:
print ("too high")
findout = int(input("Enter a number from 1 to 9 "))
i += 1
while findout < a:
print ("too low")
findout = int(input("Enter a number from 1 to 9 "))
i +=1
#while findout != a:
#print ("Incorrect")
#findout = int(input("Enter a number from 1 to 9 "))
#i += 1
guessThis()
if findout == ato be insideguessThis.