Python List | Methods in Python List | Accessing Python List| Updating Values | Looping with Code Samples

Shilpa Sreekumar
Nerd For Tech
Published in
4 min readAug 30, 2020

--

Photo by Kelly Sikkema on Unsplash

Lists in Python are a fundamental data structure that allows to store a collection of items in a specific order. It is used to store sequence of values of different types. The items in a list are enclosed within square bracket [ ] and separated by using commas (,)

For example:

sample_list_1 = [1, 2, 3, 4, 5, 6] #List with integer values
sample_list_2 = ["Apple", 10, 3.2] #List with various types
print(sample_list_1)
print(sample_list_2)

#Output:
[1, 2, 3, 4, 5, 6]
['Apple', 10, 3.2]

Python lists are mutable, ordered and modifiable. We can change the elements after creating a list.

Methods used in Python List

Python Methods

1. append()

This method is used to add an element to the end of the list.

Example:

sample_list = ["Apple", "Orange", 3]
sample_list.append("Grapes") #Adding an element to end of the list
print(sample_list)

#Output:
['Apple', 'Orange', 3,'Grapes']

2. extend()

--

--