I am trying to write a basic store-front script that loops until the customer says no to the question. Each time there's input of an Item Number, I'm trying to store it and then eventually be able to match those numbers up with the Item Name and the Price (not quite yet, though)...
I am just, now, trying to get it to add to the empty list "item_nums" instead of adding the last entry and over-writing the previous numbers.
STOREKEEPER
products = ['Notebook', 'Atari', 'TrapperKeeper', 'Jeans', 'Insects',
'Harbormaster', 'Lobotomy', 'PunkRock', 'HorseFeathers', 'Pants',
'Plants', 'Salami']
prices = ['$4.99', '$99.99', '$89.99', '$3.99', '$2.99', '$299.99',
'$19.99', '$3.99', '$4.99', '$2.99', '$119.99', '$1.99']
SKUs = [1, 2, 3, 4, 5, 6, 7, 8 ,9, 10, 11, 12]
item_nums = ()
quantity = []
response = ''
#MORE VARIABLES AND FUNCTIONS WILL GO HERE
print("Jay's House of Rip-Offs\n\n")
titles = ['Item Number', 'Item Name', 'Price']
data = [titles] + list(zip(SKUs, products, prices))
for i, d in enumerate(data):
line = '|'.join(str(x).ljust(16) for x in d)
print(line)
if i == 0:
print('-' * len(line))
response = str(input("Order products [Y / N]?: "))
while response != 'N':
item_nums = input("Enter an item number: ")
SKUs.append(item_nums)
response = str(input("Order products [Y / N]?: "))
if response == 'N':
break
print("Here is the list of items you ordered: ",item_nums[0])
Aucun commentaire:
Enregistrer un commentaire