How to insert value in python code example
Example 1: python insert
my_list = ["Add", "Answer"]
my_list.insert(1, "Grepper")
print (my_list)
> ['Add', 'Grepper', 'Answer']
Example 2: how to insert string variable into sqlite database
def create_db():
with con:
cur = con.cursor()
cur.execute("DROP TABLE IF EXISTS Contacts")
cur.execute("CREATE TABLE Contacts (First Name TEXT, Last Name TEXT, Phone TEXT, Email TEXT);")
cur.execute("INSERT INTO Contacts VALUES (?, ?, ?, ?);", (firstname, lastname, phone, email))
con.commit()
Example 3: how to add elememt in pytohn
ls=[]
ls.append('Apple')
ls.append('Mango')
for i in ls:
print(i)