Question

Python pls create a function called search_position. This function returns a dictionary. team1 = {'Fiora': {'Top':...

Python pls

create a function called search_position. This function returns a dictionary.

team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2, 'Top': 5},'Shaco': {'Jungle': 4, 'Top': 2, 'Mid': 1}}

def search_position(team1):

should return

{'Top': {'Fiora': 1, 'Yasuo':5,'Olaf':3,'Shaco':},
'Jungle': {'Shaco': 4},
'Mid': {'Yasuo', 2, 'Fiora': 4,'Olaf':2},
'Bottom': {'Fiora': 3},
'Support': {'Olaf': 4}}

Homework Answers

Answer #1
def search_position(team1):
    result = {}
    for player, positions in team1.items():
        for position, value in positions.items():
            if position not in result:
                result[position] = {}
            result[position][player] = value
    return result
# Testing the function here. ignore/remove the code below if not required
team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3}, 'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},
         'Yasuo': {'Mid': 2, 'Top': 5}, 'Shaco': {'Jungle': 4, 'Top': 2, 'Mid': 1}}
print(search_position(team1))
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python pls create a function called search_position. This function returns a list of 2 tuples and...
Python pls create a function called search_position. This function returns a list of 2 tuples and the number should be start highest number. The first index is the number, and second are list of 2 tuples that sorted by position in alphabetical order: The first index will be position and second index will be champion's name(This also should be sorted by alphabetical order). team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2,...
python pls Create function math_life() this function takes one or more argument. If this function called...
python pls Create function math_life() this function takes one or more argument. If this function called with no argument, raise typeError. The math_life() function returns to a function defined inside. this will take a one argument. For the second argument, it will calculate second function passed to math_life(). You should assume that the math_life() passed x functions, when it called the x times it will calculate the xth function passed to math_life() arguments when it called x+1 time it again...
create a function that takes a dictionary and returns a list of int. The list should...
create a function that takes a dictionary and returns a list of int. The list should appear in decreasing order based on the sum of number in each dictionary. def total_num(dict1): #Code here input = {1: {'una': 5, 'dos': 7, 'tres': 9, 'quar' : 11}, 2: {'dos':2, 'quar':3}, 3:{'una': 3, 'tres': 5}, 4:{'cin': 6}, 5:{'tres': 7 , 'cin': 8}} output = [1,5,3,4,2] 1: 38 2: 5 3: 8 4: 6 5: 15 1>5>3>4>2
Write code to create a Python dictionary called class. Add two entries to the dictionary: Associate...
Write code to create a Python dictionary called class. Add two entries to the dictionary: Associate the key 'class_name' with the value 'MAT123', and associate the key 'sect_num' with '211_145' PYTHON
Python Write the contents of the function below. It should build a dictionary with keys and...
Python Write the contents of the function below. It should build a dictionary with keys and values. For each such entry, it must enter two rows from the keyboard. The first line should constitute the key to be stored in a form with only capital letters. The user enters the value on the next row. This should be stored as an integer. If you enter a blank line as the key, the lock should end and the dictionary is returned....
1.Define a function value_to_key(d,value) that takes in a dictionary and a value as a parameter. The...
1.Define a function value_to_key(d,value) that takes in a dictionary and a value as a parameter. The function will return a list of all the keys that correspond with that value. If the value does not appear in the dictionary, it will return an empty list. ex.value_to_key({‘a’: 1, ‘b’: 4, ‘c’: 7}, 4) returns [‘b’] 2.Define a function input_tracker(number)that prompts the user to input values into the console a number of times.The function will return a dictionary where the keys are...
Python Problem 1 Create a function, biggest_ip_sum, outside of the ServerClass class, that: 1. Takes two...
Python Problem 1 Create a function, biggest_ip_sum, outside of the ServerClass class, that: 1. Takes two ServerClass objects 2. Sums the octets of the IP together (example 127.0.0.1 = 127+0+0+1 = 128) 3. Returns the larger number Example: server_one = ServerClass("127.0.0.1") server_two = ServerClass("192.168.0.1") result = biggest_ip_sum(server_one, server_two) print(result) In the example above, result will be 361. _________________________________ Problem 1 Here is the code to start with class ServerClass: """ Server class for representing and manipulating servers. """ def __init__(self,...
Create a new dictionary called quantities using {} format like. Complete the following: Put these values...
Create a new dictionary called quantities using {} format like. Complete the following: Put these values (quantity, price) in your quantities dictionary: "baskets": (4, 2.49) "boxes": (2, 1.95) "bags": (5, 1.29) "crates": (3, 5.99) Print the quantities dictionary Loop through each key in quantities. For each key, print out the key along with its corresponding quantity. Print the answer in the following format: baskets: 4 boxes: 2 bags: 5 crates: 3 Print the total number of items (should be 14)....
In python Please Problem We want to create a DHCP service that assigns a random, unique...
In python Please Problem We want to create a DHCP service that assigns a random, unique IP with subnet mask 255.0.0.0. This means the service only sets the last 3 octets of an IP. For example if the dhcp_service function is called by an IP of "192.0.0.0", it should keep the 192 and change the rest: 1. Create a dhcp_service(ip_address) function, outside of the ServerClass 2. Have request_dhcp_ip call the dhcp_service and set the ServerClass object's IP to the generated...
Create a function which returns the number of odd integers in a list (python)
Create a function which returns the number of odd integers in a list (python)