def replace_special_characters(text):
    """Replace special characters in a string

    Makes a copy of string 'text' with special characters (i.e.
    non-alphanumeric) replaced by underscores, and spaces replaced
    by hyphens.

    This is useful for generating strings to use in HTML documents."""
    ele = []
    for c in list(str(text).lower()):
        if c.isspace():
            ch = "-"
        elif not c.isalnum():
            ch = "_"
        else:
            ch = c
        ele.append(ch)
    return "".join(ele)