Answers for "add to list"

90

add something to list python

#append to list
lst = [1, 2, 3]
something = 4
lst.append(something)
#lst is now [1, 2, 3, 4]
Posted by: Guest on January-21-2020
51

python add to list

list_to_add.append(item_to_add)
Posted by: Guest on February-19-2020
14

how to add an item to a list in python

myList = [1, 2, 3]

myList.append(4)
Posted by: Guest on November-17-2019
24

append to list python

list = ["a"]
list.append("b")

print(list)
["a","b"]
Posted by: Guest on June-03-2020
8

how to add item to a list python

my_list = []
item1 = "test1"
my_list.append(item1)

print(my_list) 
# prints the list ["test1"]
Posted by: Guest on June-03-2020
0

add to list

import tkinter as tk
from tkinter import simpledialog
from tkinter import messagebox
import json

ROOT = tk.Tk()
ROOT.withdraw()

number = 0
thelist = []

while(number < 3):
    USER_INP = simpledialog.askstring(title="List",
                                  prompt="Add 3 items:")
    thelist.append(USER_INP + ",")
    number = number + 1

with open("list.json", 'w') as f:
    json.dump(thelist, f, indent=2)

with open("list.json", 'r') as f:
    thelist = json.load(f)

messagebox.showinfo("The List", thelist)
Posted by: Guest on September-22-2021

Python Answers by Framework

Browse Popular Code Answers by Language