def stations_by_river(stations):
    """creates a dictionary with river names as keys to a list of stations on each one"""
    dict_rivers={} #creates empty dictionary
    for station in stations:#iterates over all the station objects in the given list
        if station.river in dict_rivers.keys(): #checks to see if river is already in dictionary
            dict_rivers[station.river].append(station.name) #adds new station name if river has already been added as a key
        else:
            dict_rivers[station.river]=[station.name] #creates new river key if river isn't in dictionary
    return dict_rivers