How do you enter/add multiple items to a list ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do you enter/add multiple items to a list ??

to add an item, you use the append method.. example.. list=['shoe','sock','tie'] print(list) list.append('shirt') print (list) list.append('pen','paper') print (list)

6th Aug 2017, 8:20 AM
Otumian Empire
Otumian Empire - avatar
3 Answers
+ 3
um lifehack: use list concat to add multiple items [1, 2] + [3, 4]
6th Aug 2017, 8:29 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 1
If you have a bunch of lists and want to add them together, cheeze's way is the best. If you have a list, but want to add one or more variables, and the items aren't lists. You'll have to use a loop of some sort (while or for loop). There are tons of ways to do this, here's one I made to show you using a little trick. I believe it's the lazies- ... efficient. It's efficient! It'll allow you to add one, or more with a simple call to a variable. https://code.sololearn.com/ckRCst0Y6ZOJ
6th Aug 2017, 9:29 AM
Sapphire
+ 1
all your suggestions worked...thanks guys..
6th Aug 2017, 1:53 PM
Otumian Empire
Otumian Empire - avatar