Hi everyone I have recently been introduced to Python and I am attempting some activities for beginners but I have become stuck on one part.
Basically my task is to create a function that takes a list of four input values and from that an output value is formed. Each number in the list should be multiplied by the next number in the list e.g. [5,4,3,2] would be 5 * 4 * 3 * 2 then the total of this sum is then multiplied by 7 and that is the final answer. (This program should work for any combination in the list) Below I have shown my attempt. I could be so far off but it'll be good to learn from;
Basically my task is to create a function that takes a list of four input values and from that an output value is formed. Each number in the list should be multiplied by the next number in the list e.g. [5,4,3,2] would be 5 * 4 * 3 * 2 then the total of this sum is then multiplied by 7 and that is the final answer. (This program should work for any combination in the list) Below I have shown my attempt. I could be so far off but it'll be good to learn from;
def amount_of_plastic(width_brick, height_brick, length_brick, number_of_bricks): """Given the dimensions of a brick (width, height, length in cm) and the number of bricks ordered, calculate how much plastic, in grams, is required (if a cubic centimetre weighs 7 grams).""" # INSERT YOUR CODE BELOW THIS LINE FOR CALCULATING THE # AMOUNT OF PLASTIC AND RETURNING THE RESULT (DO NOT CHANGE # THE HEADER OF THE FUNCTION WHICH HAS BEEN PROVIDED FOR YOU # ABOVE) total_weight = 0 amount_of_plastic = [5, 2, 2, 20] for item in amount_of_plastic: total_weight = item * item total_weight = item * 7 return(total_weight)Any help is greatly appreciated.