You have to create a function that given an array of integers returns the largest product that can be made by multiplying any 3 integers in the array.
Example:
[-4, -4, 2, 8]
should return 128 as the largest product can be made by multiplying -4 * -4 * 8 = 128.
def maximum_product_of_three(lst):
max_pr = 0
num_num = 0
for num in lst:
for i in range(0,len(lst)):
if i != lst[num_num] and num_num+2 < len(lst):
try:
if (num*lst[i+1]*lst[i+2])>max_pr:
max_num = num*lst[i+1]*lst[i+2]
except:
pass
num_num =+ 1
return max_num
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
test.assert_equals(maximum_product_of_three([-4,-4,2,8]), 128)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings