Lists in Python
Ch. Arun
23007-CS-026
Lists
• List is a ordered collection of
elements
• Lists are created by using Square
brackets[]
• Mutable Datatype
• Lists can store different types of
Elements
Ex:- int , float , string, another list
Creating a
• Numbers List
= [1,2,3,4]
• Names = [“Arun” , “Charan” ,
“Krishna”]
Accessing List Elements:
• List elements are accessed using
index
Ex: Number[1]
List Operations
append( ) remove(value)
Removes the first occurance of the value
Add one element at the end
Ex: list = [2,3] Ex: list=[1,2,3,2]
[Link](3) [Link](2)
print(list) print(list)
Output: [1,2,3] Output: [1,3,2]
insert(index,element) pop(index)
Removes and returns elements at index
Adds element at the specific
position Ex: list=[10,20,30]
Ex: list=[1,2,4] [Link](1)
[Link](2,3) print(list)
print(list) Output: [10,30]
Output: [1,2,3,4]
Real Life Applications
• Shopping List
• Student Marks
• Packing Checklist
• To-do list
Conclusion
• Lists are an important and
flexible data structure in
Python.
• They are used to store,
manage, and manipulate
multiple values efficiently.