def stations_by_river(stations):
    """
    Given a list of station objects, returns a dictionary that maps river names
    to a list of station objects on a given river
    """
    stations_by_rivername = {}
    for station in stations:
        if station.river:
            if station.river in stations_by_rivername:
                stations_by_rivername[station.river].append(station.name)
            else:
                stations_by_rivername[station.river] = [station.name]
    return stations_by_rivername