from random import randint

min_nb = 1
max_nb = 99


def get_user_try():
    """
    This function ask to the user to enter a number between min_nb
    and max_nb. It returns an integer.
    """
    x = -1 
    while x < min_nb or x > max_nb:
        print(f"Saisir un nombre entre {min_nb} et {max_nb}.")
        try :
            x = int(input())
        except ValueError:
            print("Un nombre entier !")
            x = -1

    return x


def print_welcome():
    """
    This function print the rules of the game.
    """
    print("Le jeu du nombre secret !")
    print("Trouver le, si vous le pouvez !")
    print(f"Le nombre que vous cherchez est entre {min_nb} et {max_nb}.")
    

def print_hint(guess, secret):
    """
    This function takes two parameters, the number proposed by the
    player and the secret number, and print an hint for the player.
    """
    if guess < secret :
        print("Le nombre secret est plus grand...")
    else :
        print("Le nombre secret est plus petit...")


def main():
    print_welcome()

    # Initialisation
    secret = randint(min_nb, max_nb)
    guess = get_user_try()
    nb_of_tries = 1

    while guess != secret:
        print_hint(guess, secret)
        guess = get_user_try()
        nb_of_tries += 1
    
    print(f"Super ! Vous avez trouvé en {nb_of_tries} essais.")

    
main()


