# Products.py def shopProducts(): # List [] of Products # Product [sku,desc,price] # Create an empty list object to hold out products in memory products = [] # Create an empty list object for our product element product = [] while True: # control try: # Enter new product data sku = input("Product Sku: ") description = input("Product Decription: ") price = float( input("Enter price: ")) # Create a list from the product data using the append() product.append(sku) # [sku] product.append(description) # [sku, description] product.append(price) # [sku, description, price] # Append the new product to products products.append(product) # if clear() -> data needs to bind to something else (csv,...) product = [] # clear the user input so we can reuse the object as empty user_input = input("Do you want to add another product? (yes/no): ") # yes, YEs, YES, Yes, yes # clean data converting all char to lower case and stripping out leading and trailing whitespace lstrip() and rstrip() # handle the user spelling " yes" user_input = user_input.strip().lower() # cleanse functional sw_result = user_input.startswith("y") result = user_input[0] # analyze structural if result != "y": # anything besides "yes" loops back to the while True start position break except Exception as err: print(err) # we would want the product[] to be empty print("==== Products List =====") print(products) # function -> we would just call the function to get the output # return products # method -> we would go to the import and need to create an instance of the return in the class ''' [ ['5214', 'widget 1', 52.32], ['6573', 'widget 2', 52.32], ['4125', 'widget 3', 41.25] ] ''' # EOF