Devin Dahlberg

Python: Assignment Four

#Random number guessing game. Write a program that generates a random number in the range of 1 through 10, and asks the user to guess what the number is.
#If the user’s guess is higher than the random number, the program should display “Too high, try again.” If the user’s guess is lower than the random number, the program should display “Too low, try again.”
#If the user guesses the number, the application should congratulate the user and generate a new random number so the game can start over. You should use functions.

#Main Function
def main():
    import random
    number = random.randint(1,10)
    guessing_game(number)
    
   
   
#Guessing Game    
def guessing_game(number):
    guess = int(input('Guess a random number 1-10: '))
    if guess == number:
        print("Congrats you guessed the number!")
        main()        

    if guess > number:
        print("Too High, Try Again.")
        guessing_game(number)

    if guess < number:
        print("Too Low, Try Again.")
        guessing_game(number)
main()

CH5P1 v3