What is the fastest way to create a list/array in python BTW I am a beginner in coding😆 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the fastest way to create a list/array in python BTW I am a beginner in coding😆

7th Dec 2016, 5:57 PM
abdi
4 Answers
+ 2
mylist= ["word1","word2","word3"]
7th Dec 2016, 6:08 PM
Nahuel
Nahuel - avatar
+ 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)
7th Dec 2016, 8:20 PM
Inshal Saleem
Inshal Saleem - avatar
+ 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.
8th Dec 2016, 2:02 AM
Murat Ahmedovich
Murat Ahmedovich - avatar
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
7th Dec 2016, 6:57 PM
TotemRajal