Dec-13-2022, 01:55 AM
In this instance, it would be better to use a dictionary to save product.
example:
example:
products = { 'Iron': '24.95', 'Home Gym': '794.95', 'Microwave Oven': '165.00', 'Cordless Drill': '129.95', 'Gas Range': '495.00', 'Washer': '399.99', 'Stand Mixer': '159.95', 'Dryer': '349.95', 'Dishwasher': '595.00', 'Treadmill': '1390.00' } def get_price(product): return products[product] print(f"The price of Gas range is: ${get_price('Gas Range')}") price = get_price('Dishwasher') print(f"Dishwasher costs: ${price}")results:
Output:The price of Gas range is: $495.00
Dishwasher costs: $595.00