<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(config, stage):
 """Find default environment name in stage."""

    stage_data = get_stage_data(stage, config.get('stages', {}))
    if not stage_data:
        sys.exit(NO_STAGE_DATA.format(stage))
    try:
        return stage_data['environment']
    except KeyError:
        sys.exit(NO_ENV_IN_STAGE.format(stage))