The project is to write a game that has a randomly generated number and you need to guess the number using various functions and return statements. Whenever you try this, this code asks for your guess, then doesnt return anything.
from random import randint
TotalPoints = 0
def generateGuess():
return(randint(1,10))
def CheckGuess(playerGuess, robotGuess, correct):
correct = False
if playerGuess == robotGuess:
global TotalPoints
TotalPoints = TotalPoints + 5
correct = True
return correct
else:
correct = False
return correct
def retry ():
playagain = int(input("Do you want to play again? 1 for yes, 2 for no: "))
if (playagain == 1):
main()
elif (playagain == 2):
print("Game over! You ended with ", TotalPoints, "points!")
else:
print("error")
def main():
print("Let's play the number Guessing Game! ")
playerGuess = int(input("Make a guess: "))
robotGuess = generateGuess
CheckGuess(playerGuess, robotGuess)
if CheckGuess (correct = True):
print("You guessed right! You have ", TotalPoints, "points!")
elif CheckGuess (correct = False):
print("You lost this round!")
main()