def check_your_guess(ans, your_guess, turns, history):
    """
    The function checks whether the format of user's guess is correct
    and calculates how many left chances (depends on the format).
    :param ans: str, the answer
    :param your_guess: str, the letter user guesses
    :param turns: int, how many left chances before guess
    :param history: the collection of every letter user guesses
    :return: int, how many left chances after guess
    """
    if not your_guess.isalpha() or len(your_guess) > 1:  # not single alphabet
        print('illegal format.')
    elif your_guess in ans:
        print('You are correct!')  # correct
        if your_guess not in history:  # user guesses the same letter(correct) twice
            turns -= 1
    elif your_guess not in ans:  # wrong
        print('There is no ' + your_guess + "'s in the word.")
        turns -= 1
    return turns