Answered by : loic
# Create a list
new_list = []
# Add items to the list
item1 = "string1"
item2 = "string2"
new_list.append(item1)
new_list.append(item2)
# Access list items
print(new_list[0])
print(new_list[1])
Source : | Last Update : Wed, 10 Jun 20
Answered by : bbdd
{"tags":[{"tag":"p","content":"make list python"},{"tag":"textarea","content":"list_variable = [\"element 1\", 2, 3.0] # list with a string, integer, and float\nlist_variable2 = [\n[\"a\", \"f\", \"g\"],\n[\"b\", \"e\", \"h\"],\n[\"c\", \"d\", \"i\"] ] # 2D list","code_language":"python"}]}
Source : | Last Update : Wed, 05 Apr 23
Answered by : important-ibis-w15zx32eafiy
#creating a list
create_list = ["apple", "banana", "cherry"]
print(create_list)
Source : | Last Update : Wed, 07 Oct 20
Answered by : better-bison-gaoitu4u8512
pythonCopyl = [] # empty list
l = [2, 4, 6, 8] # elements of same data type
l = [2, 'Python', 1+2j] # elements of different data type
Source : https://www.delftstack.com/tutorial/python-3-basic-tutorial/data-type-list/#create-a-python-list | Last Update : Mon, 01 Nov 21
Answered by : david-cao
my_list = ['p', 'r', 'o', 'b', 'e']
# first item
print(my_list[0]) # p
# third item
print(my_list[2]) # o
# fifth item
print(my_list[4]) # e
# Nested List
n_list = ["Happy", [2, 0, 1, 5]]
# Nested indexing
print(n_list[0][1])
print(n_list[1][3])
# Error! Only integer can be used for indexing
print(my_list[4.0])
Source : https://www.howtouselinux.com/post/create-a-list-in-python | Last Update : Mon, 30 May 22
Answered by : better-bison-gaoitu4u8512
pythonCopyl = [[2,4,5], 'python']
Source : https://www.delftstack.com/tutorial/python-3-basic-tutorial/data-type-list/#create-a-python-list | Last Update : Mon, 01 Nov 21
Answered by : caio-fascina
string_list = ['a', 'b', 'c']
Source : | Last Update : Thu, 20 Jan 22
Answered by : pleasant-peacock-j7kylsbu49dm
List_name=["values",'string value',1,1.1,'etc']
Source : | Last Update : Mon, 25 Jan 21
Answered by : careful-crane-bxejtqudppbe
a = { "first letter in the alphabet. " "also used to describe something e.g: " "{a} cat!"
}
Source : | Last Update : Mon, 27 Jun 22