# Initialize an empty dictionary to store products and prices
products = {}
# Step 1: Enter product names and prices
while True:
# Ask the user for a product name
product_name = input("Enter product name (or 'done' to stop): ").strip()
# Break the loop if the user is done entering products
if product_name.lower() == 'done':
break
# Ask the user for the product price
try:
price = float(input(f"Enter price for {product_name}: "))
# Store product name and price in the dictionary
products[product_name] = price
except ValueError:
print("Please enter a valid number for the price.")
# Print out the created dictionary
print("Products and their prices:", products)
# Step 2: Allow the user to look up product prices below a certain amount
try:
# Ask the user to enter a dollar amount
amount = float(input("Enter a dollar amount to find products below this price:
"))
print(f"Products with prices less than ${amount:.2f}:")
# Check and print products with prices less than the specified amount
for product, price in products.items():
if price < amount:
print(f"{product}: ${price:.2f}")
except ValueError:
print("Please enter a valid number for the dollar amount.")