from typing import List


def snake(n: str) -> str:
    """Convert a string in upper or lower camel case to snake case"""
    out: List[str] = []
    for c in n:
        if c.isupper() and out:
            out.append("_")
            out.append(c.lower())
        else:
            out.append(c.lower())
    return "".join(out)