0
What is the fastest way to create a list/array in python BTW I am a beginner in coding😆
4 Respostas
+ 2
mylist= ["word1","word2","word3"]
+ 1
list=['Sucess','Patience','Courage']
#You use this as it is simple you can also get input the elements of list from user.As described below:
list=[]
count=0
while count<3:
count=int(input("Enter values"))
list.append(count)
count+=1
print(list)
+ 1
# first name of array/list
listName=[]
print(type(listName)) # it is list.. but empty.
# convert something to list is just calling list() function pass into the paranthesis what you want to make list.
0
# like this :
mylist = list()
# use it like an object
mylist.append("toto")
mylist()
>> ["toto"]
# but
mylist = []
# is the same like
mylist = list()
# by convention it's better to use list()
# for create a list object
k