def add_python_snippet(txt: str, expandable: bool = True):
    """
    Add a python snippet.

    :param txt: A string object.
    :param expandable: If true, puts code in <details></details> syntax.
    :return: Python string markdown syntax.
    """
    md_str = f"\n```python\n{txt}\n```"

    if expandable:
        md_str = f"\n<details>\n<summary>source code</summary>\n{md_str}\n</details>\n"

    return md_str