Exemple #1
0
def players_by_position(squads_list):
    # Reassign the list to new variable to be safe
    postions_list = squads_list
    # Empty dictionary that will be returned
    players_dict = {'GK': [], 'MF': [], 'FW': []}

    # Pass the new assigned list to dictionary function from assignment_1 and loop through
    for player in players_as_dictionaries(postions_list):
        # Look for 'GK' position
        if player['position'] == 'GK':
            # Append player to 'GK' key
            players_dict['GK'].append(player)

        # Look for 'MF' position
        if player['position'] == 'MF':
            # Append player to 'MF' key
            players_dict['MF'].append(player)

        # Look for 'FW' position
        if player['position'] == 'FW':
            # Append player to 'FW' key
            players_dict['FW'].append(player)

    return players_dict


#players_by_position(SQUADS_DATA)
Exemple #2
0
def players_by_position(squads_list):
    list_of_players = asd.players_as_dictionaries(squads_list)
    player_dict = {}
    for player in list_of_players:
        player_dict.setdefault(player['position'], [])
        player_dict[player['position']].append(player)
    return player_dict
def players_by_position(squads_list):
    players = players_as_dictionaries(squads_list)

    position_dict = {}
    for player in players:
        position_dict.setdefault(player["position"], [])
        position_dict[player["position"]].append(player)
    return position_dict
Exemple #4
0
def players_by_position(squads_list):    
    positions = {}
    position = ''
    for player in players_as_dictionaries(squads_list):
        position = player['position']
        positions.setdefault(position,[])
        positions[position].append(player)
    return positions
def players_by_position(squads_list):
    players = players_as_dictionaries(squads_list)
    finaldict = {}
    for item in range(len(players)):
        position = players[item]['position']
        finaldict.setdefault(position, [])
        finaldict[position].append(players[item])
    return finaldict
def players_by_position(squads_list):
    result = {}
    players = players_as_dictionaries(squads_list)
    for player in players:
        position = player['position']
        result.setdefault(position, [])
        result[position].append(player)
    return result
Exemple #7
0
def players_by_position(squads_list):
    position_dict={}
    squads_data=players_as_dictionaries(squads_list)
    for squad_pos in squads_data:
        position=squad_pos['position']
        position_dict.setdefault(position,[])
        position_dict[position].append(squad_pos)
    return position_dict
Exemple #8
0
def players_by_country_and_position(squads_list):
    list_of_players = asd.players_as_dictionaries(squads_list)
    country_dict = {}
    for player in list_of_players:
        country_dict.setdefault(player['country'], {})
        country_dict[player['country']].setdefault(player['position'], [])
        country_dict[player['country']][player['position']].append(player)
    return country_dict
Exemple #9
0
def players_by_position(squads_list):
    players_list = players_as_dictionaries(squads_list)
    players_by_pos_dict = {}
    for player in players_list:
        position = player['position']
        players_by_pos_dict.setdefault(position, [])
        players_by_pos_dict[position].append(player)
    return players_by_pos_dict
Exemple #10
0
def players_by_position(squads_list):
    squad_dict = players_as_dictionaries(squads_list)
    pos_dict = {}
    for player in squad_dict:
        pos = player.get('position')
        pos_dict.setdefault(pos, [])
        pos_dict[pos].append(player)
    return pos_dict
Exemple #11
0
def players_by_position(squads_list):
    pos_players = {}
    list_dic_players = players_as_dictionaries(squads_list)
    for player in list_dic_players:
        position = player["position"]
        pos_players.setdefault(position,[])
        pos_players[position].append(player)
    return pos_players
Exemple #12
0
def players_by_position(squads_list):
    nation = {}
    players = players_as_dictionaries(squads_list)
    for player in players:
        position = player['position']
        nation.setdefault(position, [])
        nation[position].append(player)
    return nation
    
Exemple #13
0
def players_by_position(squads_list):
    squad = players_as_dictionaries(squads_list) ## now we have access to the list of dictionaries
    
    results = {}
    for player in squad:
        position = player['position'] # get the value of the key "position"
        results.setdefault(position, []) #return position or return default if none
        results[position].append(player)
    return results
def players_by_position(squads_list):
    positions_dict = {}
    for player in players_as_dictionaries(squads_list):
        if player["position"] not in positions_dict.keys():
            positions_dict.setdefault(player['position'], [player])
        else:
            positions_dict[player["position"]].append(player)

    return positions_dict
Exemple #15
0
def players_by_position(squads_list):
    result = {}

    for player in players_as_dictionaries(squads_list):

        result.setdefault(player['position'], [])
        result[player['position']].append(player)

    return result
def players_by_position(squads_list):
    final_dict = {}
    player_list_of_dictionaries = players_as_dictionaries(squads_list)

    for player in player_list_of_dictionaries:
        position = player["position"]
        final_dict.setdefault(position, [])
        final_dict[position].append(player)
    return final_dict
def players_by_country_and_position(squads_list):
    country_dict = {}
    players = players_as_dictionaries(squads_list)
    for country_player in players:
        country = country_player['country']
        position = country_player['position']
        country_dict.setdefault(country, {})
        country_dict[country].setdefault(position, [])
        country_dict[country][position].append(country_player)
    return country_dict
Exemple #18
0
def players_by_position(squads_list):
    new_squad_list = players_as_dictionaries(squads_list)
    by_position = {}

    for player in new_squad_list:
        position = player['position']
        by_position.setdefault(position, [])
        by_position[position].append(player)

    return by_position
Exemple #19
0
def players_by_position(squads_list):
    mydict = players_as_dictionaries(squads_list)
    newdict = {}

    for players in mydict:
        group_by_position = players['position']
        newdict.setdefault(group_by_position, [])
        newdict[group_by_position].append(players)

    return newdict
def players_by_position(squads_list):
    squads_list = players_as_dictionaries(squads_list)  # must format list (again) from data
    positions = {}  # declare dict for storage 
    
    for player in squads_list:
        position_key = player['position']       # find the player's postn in list (eg GK)
        positions.setdefault(position_key, [])  # set the key to None or error
        positions[position_key].append(player)  # append entire player by his position
    
    return positions
def players_by_country_and_position(squads_list):
    players_by_country_pos={}
    players_list= players_as_dictionaries(squads_list)
    for player in players_list:
        country = player['country']
        position = player['position']
        players_by_country_pos.setdefault(country, {})
        players_by_country_pos[country].setdefault(position,[])
        players_by_country_pos[country][position].append(player)
    return players_by_country_pos
def players_by_country_and_position(squads_list):
    nation = {}
    players = players_as_dictionaries(squads_list)
    for player in players:
        position = player['position']
        country = player['country']
        nation.setdefault(country,{})
        nation[country].setdefault(position, [])
        nation[country][position].append(player)
    return nation
def players_by_position(squads_list):

    players = players_as_dictionaries(squads_list)

    results = {'GK': [], 'MF': [], 'FW': []}

    for individual_player in players:
        results[individual_player['position']].append(individual_player)

    return results
Exemple #24
0
def players_by_country_and_position(squads_list):
    result = {}
    players = players_as_dictionaries(squads_list)
    for player in players:
        country = player['country']
        position = player['position']
        result.setdefault(country, {})
        result[country].setdefault(position, [])
        result[country][position].append(player)
    return result
def players_by_position(squads_list):
    #create empty dictionary
    position_dict = {}
    # run step 1s function
    players = players_as_dictionaries(squads_list)
    for player in players:
        position = player['position'] 
        position_dict.setdefault(position, [])
        position_dict[position].append(player)
        
    return position_dict
Exemple #26
0
def players_by_country_and_position(squads_list):
    country_dict = {}
    for player in players_as_dictionaries(squads_list):
        if player['country'] not in country_dict.keys():
            country_dict.setdefault(player['country'], {})
        if player["position"] not in country_dict[player['country']]:
            country_dict[player['country']].setdefault(player['position'],
                                                       [player])
        else:
            country_dict[player['country']][player["position"]].append(player)
    return country_dict
def players_by_position(squads_list):
    positions = {'GK': [], 'MF': [], 'FW': []}
    players = players_as_dictionaries(squads_list)
    for player in players:
        if player['position'] == 'MF':
            positions['MF'].append(player)
        elif player['position'] == 'FW':
            positions['FW'].append(player)
        elif player['position'] == 'GK':
            positions['GK'].append(player)
    return positions
Exemple #28
0
def players_by_position(squads_list):
    position_list = {}
    
    players = players_as_dictionaries(squads_list)
    for player in players:
        position = player['position']
        position_list.setdefault(player['position'], [])
        position_list[position].append(player)
        
    
    return position_list
def players_by_country_and_position(squads_list):
    squad_dict = players_as_dictionaries(squads_list)
    country_dict = {}
    for player in squad_dict:
        country = player.get('country')
        position = player.get('position')
        country_dict.setdefault(country, {})
        country_dict[country].setdefault(position, [])
        country_dict[country][position].append(player)

    return country_dict
def players_by_position(squads_list):
    player_roles = {}
    player_dictionary = players_as_dictionaries(squads_list)
    for player in player_dictionary: 
        player_roles.setdefault(player['position'], [])
        player_roles[player['position']].append(player)
    return player_roles

# players in playdict
# check key for value if keys match then append to player roles
# build something to compare what player@
# return player roles as dict
def test_assignment_1():
    result = players_as_dictionaries(SQUADS_DATA)
    assert len(result) == 14

    assert result[0] == {
        'caps': '',
        'club': 'Quilmes',
        'club_country': 'Argentina',
        'country': 'Argentina',
        'date_of_birth': '(1908-10-23)23 October 1908 (aged 21)',
        'name': 'Juan Botasso',
        'number': '1',
        'position': 'GK',
        'year': '1930'
    }

    assert result[1] == {
        'caps': '',
        'club': 'Boca Juniors',
        'club_country': 'Argentina',
        'country': 'Argentina',
        'date_of_birth': '(1907-02-23)23 February 1907 (aged 23)',
        'name': 'Roberto Cherro',
        'number': '9',
        'position': 'FW',
        'year': '1930'
    }

    assert result[-1] == {
        'caps': '26',
        'club': 'Ulsan Hyundai',
        'club_country': 'South Korea',
        'country': 'South Korea',
        'date_of_birth': '(1988-04-14)14 April 1988 (aged 26)',
        'name': 'Kim Shin-Wook',
        'number': '-',
        'position': 'FW',
        'year': '2014'
    }