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:
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started