Python Forum
Help With Python SQLite Error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help With Python SQLite Error
#11
(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?
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.
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?
#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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  need help with data analysing with python and sqlite Hardcool 2 404 Jan-30-2024, 06:49 AM
Last Post: Athi
  python sqlite autoincrement in primary column janeik 6 1,228 Aug-13-2023, 11:22 AM
Last Post: janeik
  Help with subtracting values using SQLite & Python Extra 10 3,513 May-10-2022, 08:36 AM
Last Post: ibreeden
  [Solved]Help with search statement-SQLite & Python Extra 1 1,076 May-06-2022, 07:38 PM
Last Post: Extra
  Python Sqlite georgebijum 0 1,076 May-04-2022, 10:12 AM
Last Post: georgebijum
  Error while transferring data from sqlite to elasticsearch - please help! ps96068 1 2,717 Jun-12-2021, 09:24 AM
Last Post: ibreeden
  SQLite Unique constraint failed error djwilson0495 3 13,580 Aug-14-2020, 05:23 PM
Last Post: ndc85430
  Importing data from a text file into an SQLite database with Python macieju1974 7 4,210 Jun-29-2020, 08:51 PM
Last Post: buran
  how to use items combobox in table name sqlite in python hampython 1 2,719 May-24-2020, 02:17 AM
Last Post: Larz60+
  Error SQLite objects created in a thread can only be used in that same thread. binhduonggttn 3 15,678 Jan-31-2020, 11:08 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020