<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_environment():
 """Get the environment in which halo is running Returns ------- str Environment name """

    try:
        from IPython import get_ipython
    except ImportError:
        return 'terminal'

    try:
        shell = get_ipython().__class__.__name__

        if shell == 'ZMQInteractiveShell':  # Jupyter notebook or qtconsole
            return 'jupyter'
        elif shell == 'TerminalInteractiveShell':  # Terminal running IPython
            return 'ipython'
        else:
            return 'terminal'  # Other type (?)

    except NameError:
        return 'terminal'