import string
import random


def password(length: int = 16):
    """
    Creates a secure password of the specified length.

    Parameters
    ----------
    length: int
        The length of the password should be.

    Raises
    ------
    ValueError
        If the password is less than 8 or more than 16 characters long.

    Returns
    -------
    password: str
        The Password that was generated
    """
    password = []
    chars = list(string.ascii_letters + string.digits + "!@#$%^&*()")
    random.shuffle(chars)

    try:
        if length > 16 or length < 8:
            raise ValueError(
                "The password can be no longer than 16 characters and no shorter than eight characters."
            )
        password.extend(random.choice(chars) for _ in range(length))
        return "".join(password)
    except Exception as e:
        raise e from e