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 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 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)
Write a Python program to create a dictionary from two lists without losing duplicate values. If...
Write a Python program to create a dictionary from two lists without losing duplicate values. If there is more values in the key list, then provided key should return an empty set if there is no match. (Hint: use defaultdict) Example: class_list = ['Class-V', 'Class-VI', 'Class-VII', 'Class-VIII','Class-IX'] id_list = [1, 2, 2, 3] Output: assuming you store the values in a data structure named temp print(temp["Class-V"]) # {1} print(temp["Class-IX"]) # set() can you please try and do on google colab
Python Mutable Sequences Implement a function reverse that takes a list as an argument and reverses...
Python Mutable Sequences Implement a function reverse that takes a list as an argument and reverses the list. You should mutate the original list, without creating any new lists. Do NOT return anything. Do not use any built-in list functions such as reverse(). def reverse(lst):    """Reverses lst in place (i.e. doesn't create new lists).     >>> L = [1, 2, 3, 4]     >>> reverse(L)     >>> L     [4, 3, 2, 1]     """
Using C programming Create a function called printMenu( ) with the following properties: Has no function...
Using C programming Create a function called printMenu( ) with the following properties: Has no function inputs or output. Prints the following menu to the screen: 1. Enter user name. 2. Enter scores. 3. Display average score. 4. Display summary. 5. Quit Create a function called printLine( ) with the following properties: Takes as input a char Takes as input an integer corresponding to the number of times to print the character Has no function output. For example, if we...