Advertisement
Guest User

StockSearch

a guest
Apr 6th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. with open("stock.txt") as stockfile:
  2.     stock = [{"ID":a, "Size":b, "Color":c, "Model":d, "Store": e, "Warehouse":f} for a, b, c, d, e, f in [line.split() for line in stockfile.read().splitlines()]]
  3.  
  4. def search(stock):
  5.     model = input("Model Number: ")
  6.     size = input("Size: ")
  7.     color = input("Color: ")
  8.  
  9.     if size: stock = [i for i in stock if i["Size"].upper()==size.upper()]
  10.     if color: stock = [i for i in stock if i["Color"].upper()==color.upper()]
  11.     stock = [i for i in stock if i["Model"]==model]
  12.  
  13.     print("\nRestults:\n"+'\n'.join([f"Model: {i['Model']}, Size: {i['Size']}, Color: {i['Color']}, Number in store: {i['Store']}, Number in warehouse: {i['Warehouse']}" for i in stock]) if stock else "\nNo Results\n")
  14.  
  15.  
  16. while True:
  17.     search(stock)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement