Skip to content
← Back to Community
How do we make a list on python?
Profile icon
KidDanger

I need help making a list in python.

Answered by Bookie0 [earned 5 cycles]
View Answer
Voters
Profile icon
dominicrivera1130
Profile icon
KidDanger
Comments
hotnewtop
Profile icon
Bookie0

A list is basically a collection which is ordered and can be changed.
You just do it like this:

my_list = [“item1”, “item2”, “item3”, “item4”] # replace those with what you want. # you can have as much values inside as you want

You can also access certain parts of the list with indexes. Indexes always start at 0

Example:

food = [“pizza”, “hotdog”, “rice”] print (food[0]) # this will print “pizza” because it is the first value of the list. print (food[2]) # will print “rice”

reminder: lists always start at index 0, so pizza is at index 0, hotdog at index 1, and rice at index 2.

For more help check these out: https://www.w3schools.com/python/python_lists.asp

https://www.programiz.com/python-programming/list

https://www.geeksforgeeks.org/python-list/

https://www.tutorialspoint.com/python/python_lists.htm

Happy coding and hope this helps! =)

Profile icon
KidDanger

You say list name then .append"_____"and that will add something to the end of your list and saying ________fruits[4]="MANGO"will add mango in your list.

Profile icon
VulcanWM

Making a list is simple, just name the list a variable and put all its values in these: [].
So an example is:

fruits = ["orange","apple","grape","pear"]

Mark this as the answer if was helpful or userful.

Profile icon
KidDanger

what does append mean

Profile icon
KidDanger

How do I add something to my list and replace or take something away from my list.