I made a prior discussion where I was unable to properly explain myself. This is my most up to date code that does what I want with 3 items. I would like to turn this into a function using a list so that it can ask how many items you want to use and then run the code that I have so it is not manually inputted 3 separate times but is instead expandable to however many items are needed.
unit = "pounds"
pounds = 0.00220462
weightA = float(input("What is the weight of Specimen A? "))
converted_weightA = float(weightA * pounds)
formatted_floatA = "{:.2f}".format(converted_weightA)
#print('Specimen A is ' + formatted_floatA + ' ' + unit)
weightB = float(input("What is the weight of Specimen B? "))
converted_weightB = float(weightB * pounds)
formatted_floatB = "{:.2f}".format(converted_weightB)
#print('Specimen B is ' + formatted_floatB + ' ' + unit)
weightC = float(input("What is the weight of Specimen C? "))
converted_weightC = float(weightC * pounds)
formatted_floatC = "{:.2f}".format(converted_weightC)
#print('Specimen C is ' + formatted_floatC + ' ' + unit)
totalcost = float(input("What is the total price of the lot?: "))
totalweight = converted_weightA + converted_weightB + converted_weightC
IndividualPriceA = (converted_weightA / totalweight) * (totalcost * 3)
IndividualPriceB = (converted_weightB / totalweight) * (totalcost * 3)
IndividualPriceC = (converted_weightC / totalweight) * (totalcost * 3)
print('Specimen A is ' + formatted_floatA + ' ' + unit + ' and is worth $',IndividualPriceA)
print('Specimen B is ' + formatted_floatB + ' ' + unit + ' and is worth $', IndividualPriceB)
print('Specimen C is ' + formatted_floatC + ' ' + unit + ' and is worth $', IndividualPriceC)
input()
