How do we make a list on python?
I need help making a list in python.
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
food = [“pizza”, “hotdog”, “rice”] print (food) # this will print “pizza” because it is the first value of the list. print (food) # 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
Happy coding and hope this helps! =)