Question: Please solve in Python Write a function that takes in a list of lists, where each inner list is of the above form (assume there

Please solve in Python

Write a function that takes in a list of lists, where each inner list is of the above form (assume there are always 3 elements in the inner list) and returns a dictionary where the keys are the labels for a slot machine (i.e. 1, 2 and 3) and the values are the total amount of money either won or lost for a particular slot machine:

{1: , 2: , 3: }

Notes:

If the input list is empty, then the dictionary values should be 0 for all slot machines.

You dont need to define magic numbers for the strings 1, 2, and 3. In general, we dont treat strings as magic numbers in this class.

def gambling_in_vegas(profit_history):

"""

>>> gambling_in_vegas ([[-123, -231, -82], [-340, -158, -225]])

{'1': -463, '2': -389, '3': -307}

>>> gambling_in_vegas([[-865, -342, 5]])

{'1': -865, '2': -342, '3': 5}

>>> gambling_in_vegas([[-954, -234, -235], [-1040, -350, -394], [-70, -43, -23]])

{'1': -2064, '2': -627, '3': -652}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!