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

I need help making a list in python.

You are viewing a single comment. View All
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! =)