May-04-2022, 11:42 PM
(May-04-2022, 07:18 AM)ibreeden Wrote: [ -> ](May-03-2022, 10:47 PM)Extra Wrote: [ -> ]But how do I get it so it repeats and creates a new list every time?Your code looks quite nice so I don't know exactly what your problem is. Is it the part "creates a new list every time"? You should not create the list again. Do you mean to have something like this?
I know for the repeating part I'll use a while loop (while input does not equal "Q" or "quit" (or something like that)), but I don't know how to put the new inputted info into a new list and not overwrite the old one.
#Creatie an empty list Item = [] while True: #Elements for the list name = (input("Item Name (Q to Quit): ")) if name == "Q": break price = (input("Item Price: ")) quantity = (input("Item Quantity: ")) description = (input("Item Description: ")) category = (input("Item Category: ")) ItemInfo = (name,price,quantity,description,category) Item.append(ItemInfo) #Append the ItemInfo to the Item list. print(Item) #Print the list
Yes, thanks. This also answers my question too.
Now I can continually take in inputs and add them to new lists!
Ultimately I was looking to add it to my SQLite Table once I had all the lists but mentor01 already answered on how to do that.
But your answer also helps me out on another project that links to my current one. So Thanks.