def stations_by_river(stations):
    """Given list of MonitoringStation objects; returns dictionary mapping river
    names to a list of MonitoringStation objects, which lie on that river."""

    output = {}
    for station in stations:
        if station.river not in output:
            output[station.river] = [station]
        else:
            output[station.river].append(station)
    
    return output