def station_by_river(stations):
    """creates a dictionary that maps a river to stations that lie on it. 
    For a given river the output should be a list of stations"""
    rivers_station = {}
    for station in stations:
        river = station.river
        station = station.name
        if river in rivers_station:
            rivers_station[river].append(station)
        else:
            rivers_station[river] = [station]
    return rivers_station