I need to request 3 items from a user then,
- Request the price of those three items from a user
- Calculate the total of all three
- Calculate the average
- print a statement saying "the total of product 1, product 2, product 3 is xxxx and the average is xxxx
I've tried to use 6 strings (so 3 for the products and 3 for the prices) so I could call each value separately. But then I was told an array would greatly shorten the code and neaten it up so I tried that but I'm battling to call it forward. I know how to work out the average and total but I'm struggling with the array part.
products =  products = input("Please enter three shopping products: ")
The code then prints and allows me to input the 3 products like below: Please enter three shopping products: Shampoo, Soap, Bread (I still need to ask the prices for each product through an array)
shopping = products print(shopping) S
The first way I tried was the 6 strings, like below:
product1 = input("Please enter a shopping item: ") product2 = input("Please enter a second shopping item: ") product3 = input("Please enter a third shopping item: ") price1 = input("Please enter the price for the first shopping item: ") price2 = input("Please enter the price for the second shopping item: ") price3 = input("Please enter the price for the third shopping item: ")
It prints the question and allows my input, but it doesn't look very neat. I now need to calculate the average of the prices as well as the total (which I can do without the array but if I'm using the array it's confusing) I'm wanting my end result to be:
The Total of [product1], [product2], [product3] is Rxx, xx and the average price of the items are Rxx, xx.