R Mac
0
Q:

how to make a list in python

listName = [1,2,3,4]
19
# 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])   
7
#creating a list
create_list = ["apple", "banana", "cherry"]
print(create_list)
3
myList = [value,value,value] #note that you can use any amount of value
#you don not have to use value
2
# empty list
my_list = []

# list of integers
my_list = [1, 2, 3]

# list with mixed data types
my_list = [1, "Hello", 3.4]
6
list = [1, 2, 4, 5, 6]
6
list = [1, 2, 3, 4, 5, 6, 7]
3
# list with numbers
list = [10, 20, 30]
# list with strings
list = ["john", "kai", "albert"]
# mixed data
list = ["john",1 ,True ]
0

New to Communities?

Join the community