I have a def running inside of an if function, but when it's supposed to start it doesn't. Below is a copy of the code I wrote. Before I had the if statement for the two games, it ran just fine just as a single def.
print("Please choose from one of the following: \n")
print("1. Tic-Tac-Toe. \n")
print("2. Number Guessing Game. \n")
playerQuestion = input("")
print("You have selected game " + playerQuestion + "! Starting the game up. . . ")
sleep(2)
if playerQuestion == 1:
print("1")
def guessingGame():
for i in range(5):
print("")
playerGuess = ()
computerNumber = (randrange(100))
playerGuess = int(input("I am thinking of a number... Please make your first guess! "))
tries = 1
while playerGuess != computerNumber:
tries += 1
if (playerGuess > computerNumber):
print("Lower! \n")
playerGuess = ()
playerGuess = int(input("I am thinking of a number... Please make your next guess! "))
elif (playerGuess < computerNumber):
print("Higher! \n")
playerGuess = ()
playerGuess = int(input("I am thinking of a number... Please make your next guess! "))
if playerGuess == computerNumber:
tries = str(tries)
print("You got it in " + tries + " tries! Congratulations! ")
again = str(input("Do you want to play again (type yes or no): "))
again = again.lower()
again = again[:1]
if again == "y":
guessingGame()
else:
sleep(1)
print("Thank you for playing! ")
guessingGame()
sleep(10)
else:
def TicTacToe():
board = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
]
for i in range(5):
print(board)