Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
940 B
4
Indexable
Never
#exe7_Create a function to search for a product in the 
#warehouse, taking as input the product name and 
#returning the price and available quantity.

def create_warehouse():
    warehouse = {}
    while True:
        name = input("Enter product name (or type 'done' to finish): ")
        if name == 'done':
            break
        quantity = int(input("Enter quantity: "))
        price = float(input("Enter price: "))
        warehouse[name] = {"quantity": quantity, "price": price}
    return warehouse

def search_product(warehouse, search_name):
    if search_name in warehouse:
        return f"Price: {warehouse[search_name]['price']}, Quantity: {warehouse[search_name]['quantity']}"
    else:
        return "Product not found"

# Example usage
my_warehouse = create_warehouse()
search_term = input("Enter product name to search for: ")
result = search_product(my_warehouse, search_term)
print(result)