SlideShare a Scribd company logo
List In Python Programming
1
Introduction to Lists in Python
Lists are a fundamental data structure in
Python that can hold an ordered collection
of items.
Lists are mutable, which means that you
can change, add, or remove elements in a
list.
Lists are defined by enclosing elements in
square brackets [].
2
Creating Lists
Lists can contain elements of different data
types, such as integers, strings, or even
other lists.
You can create an empty list by using
empty square brackets: my_list = [].
Lists can be created with elements by
separating them with commas: my_list = [1,
'apple', True].
3
Accessing List Elements
You can access individual elements in a list
by using their index, which starts at 0 for
the first element.
Negative indices can be used to access
elements from the end of the list, starting
with -1 for the last element.
Slicing allows you to access a subset of
elements in a list by specifying a start and
end index: my_list[1:3].
4
Modifying Lists
You can modify elements in a list by
assigning a new value to a specific index:
my_list[0] = 10.
Appending elements to a list can be done
using the append() method:
my_list.append('banana').
Extending a list with another list can be
achieved using the extend() method:
my_list.extend([4, 5, 6]).
5
List Methods
The len() function can be used to
determine the number of elements in a list:
len(my_list).
The insert() method allows you to add an
element at a specific index in a list:
my_list.insert(1, 'orange').
The remove() method removes the first
occurrence of a specified value in a list:
my_list.remove('apple').
6
List Operations
You can concatenate two lists using the +
operator: new_list = my_list + [7, 8, 9].
The
operator can be used to repeat a list a
certain number of times: repeated_list =
my_list
7
List Comprehensions
List comprehensions provide a concise way
to create lists based on existing lists.
Syntax: [expression for item in iterable if
condition].
Example: squares = [x
8
Conclusion
Lists are versatile and powerful data
structures in Python that allow for efficient
manipulation and storage of elements.
Understanding how to work with lists is
essential for writing efficient and effective
Python code.
Practice using lists in different scenarios to
enhance your programming skills and
problem-solving abilities.

More Related Content

PDF
Python_Lists_. Full_Presentation.pdf
sukeerthankoyyada
 
PDF
Data type list_methods_in_python
deepalishinkar1
 
PPTX
Python _dataStructures_ List, Tuples, its functions
VidhyaB10
 
PPTX
Python list
ArchanaBhumkar
 
PPTX
PROBLEM SOLVING AND PYTHON PROGRAMMING PPT
MulliMary
 
PDF
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
PPTX
lists_list_of_liststuples_of_python.pptx
ShanthiJeyabal
 
PPTX
Lecture2.pptx
Sakith1
 
Python_Lists_. Full_Presentation.pdf
sukeerthankoyyada
 
Data type list_methods_in_python
deepalishinkar1
 
Python _dataStructures_ List, Tuples, its functions
VidhyaB10
 
Python list
ArchanaBhumkar
 
PROBLEM SOLVING AND PYTHON PROGRAMMING PPT
MulliMary
 
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
lists_list_of_liststuples_of_python.pptx
ShanthiJeyabal
 
Lecture2.pptx
Sakith1
 

Similar to List In Python Programming. The linked list (20)

PPTX
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
DeepakRattan3
 
PPTX
List in Python
Sharath Ankrajegowda
 
PDF
List,tuple,dictionary
nitamhaske
 
PPTX
Python Array Power Point Presentation.pptx
MeowTwo2
 
PPTX
powerpoint 2-13.pptx
JuanPicasso7
 
PDF
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
Guru Nanak Technical Institutions
 
DOCX
List Data Structure.docx
manohar25689
 
PPTX
fundamental of python --- vivek singh shekawat
shekhawatasshp
 
PPTX
Chapter 15 Lists
Praveen M Jigajinni
 
PPTX
Python list concept
DrJSaiGeetha
 
PDF
Python programing basic knowledge hh.pdf
raviofficialmrm06
 
PPT
White paper on tuples
ArehoYoutuber
 
PPTX
PYTHON.pptx
rohithprakash16
 
PDF
Module 2-Lists,Tuple and Dictionary Final by Dr.SV (1).pdf
SURESHA V
 
PPTX
Python Lecture 8
Inzamam Baig
 
PPTX
listtupledictionary-2001okdhfuihcasbdjj02082611.pptx
meganathan162007
 
PPTX
Pythonlearn-08-Lists.pptx
MihirDatir
 
PPTX
Python - List, Dictionaries, Tuples,Sets
Mohan Arumugam
 
PYTHON-PROGRAMMING-UNIT-III.pptx kghbg kfhjf jruufg jtuuf
DeepakRattan3
 
List in Python
Sharath Ankrajegowda
 
List,tuple,dictionary
nitamhaske
 
Python Array Power Point Presentation.pptx
MeowTwo2
 
powerpoint 2-13.pptx
JuanPicasso7
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
Guru Nanak Technical Institutions
 
List Data Structure.docx
manohar25689
 
fundamental of python --- vivek singh shekawat
shekhawatasshp
 
Chapter 15 Lists
Praveen M Jigajinni
 
Python list concept
DrJSaiGeetha
 
Python programing basic knowledge hh.pdf
raviofficialmrm06
 
White paper on tuples
ArehoYoutuber
 
PYTHON.pptx
rohithprakash16
 
Module 2-Lists,Tuple and Dictionary Final by Dr.SV (1).pdf
SURESHA V
 
Python Lecture 8
Inzamam Baig
 
listtupledictionary-2001okdhfuihcasbdjj02082611.pptx
meganathan162007
 
Pythonlearn-08-Lists.pptx
MihirDatir
 
Python - List, Dictionaries, Tuples,Sets
Mohan Arumugam
 
Ad

Recently uploaded (20)

PPTX
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PPTX
easa module 3 funtamental electronics.pptx
tryanothert7
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
Introduction of deep learning in cse.pptx
fizarcse
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PPTX
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PDF
Zero carbon Building Design Guidelines V4
BassemOsman1
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
easa module 3 funtamental electronics.pptx
tryanothert7
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Introduction of deep learning in cse.pptx
fizarcse
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
22PCOAM21 Data Quality Session 3 Data Quality.pptx
Guru Nanak Technical Institutions
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
Zero carbon Building Design Guidelines V4
BassemOsman1
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Ad

List In Python Programming. The linked list

  • 1. List In Python Programming
  • 2. 1 Introduction to Lists in Python Lists are a fundamental data structure in Python that can hold an ordered collection of items. Lists are mutable, which means that you can change, add, or remove elements in a list. Lists are defined by enclosing elements in square brackets [].
  • 3. 2 Creating Lists Lists can contain elements of different data types, such as integers, strings, or even other lists. You can create an empty list by using empty square brackets: my_list = []. Lists can be created with elements by separating them with commas: my_list = [1, 'apple', True].
  • 4. 3 Accessing List Elements You can access individual elements in a list by using their index, which starts at 0 for the first element. Negative indices can be used to access elements from the end of the list, starting with -1 for the last element. Slicing allows you to access a subset of elements in a list by specifying a start and end index: my_list[1:3].
  • 5. 4 Modifying Lists You can modify elements in a list by assigning a new value to a specific index: my_list[0] = 10. Appending elements to a list can be done using the append() method: my_list.append('banana'). Extending a list with another list can be achieved using the extend() method: my_list.extend([4, 5, 6]).
  • 6. 5 List Methods The len() function can be used to determine the number of elements in a list: len(my_list). The insert() method allows you to add an element at a specific index in a list: my_list.insert(1, 'orange'). The remove() method removes the first occurrence of a specified value in a list: my_list.remove('apple').
  • 7. 6 List Operations You can concatenate two lists using the + operator: new_list = my_list + [7, 8, 9]. The operator can be used to repeat a list a certain number of times: repeated_list = my_list
  • 8. 7 List Comprehensions List comprehensions provide a concise way to create lists based on existing lists. Syntax: [expression for item in iterable if condition]. Example: squares = [x
  • 9. 8 Conclusion Lists are versatile and powerful data structures in Python that allow for efficient manipulation and storage of elements. Understanding how to work with lists is essential for writing efficient and effective Python code. Practice using lists in different scenarios to enhance your programming skills and problem-solving abilities.

Editor's Notes

  • #3: Image source: https://morioh.com/a/18b4d4b4b161/python-data-structures-linked-list
  • #4: Image source: http://www.btechsmartclass.com/python/Python_Tutorial_Python_Lists.html
  • #5: Image source: https://www.youtube.com/watch?v=g0ClJ28-8LE
  • #6: Image source: http://www.btechsmartclass.com/python/Python_Tutorial_Python_Lists.html
  • #7: Image source: http://codescracker.com/python/python-len-function.htm
  • #8: Image source: https://www.scientecheasy.com/2023/02/concatenate-lists-in-python.html/
  • #9: Image source: https://www.freecodecamp.org/news/list-comprehension-in-python/
  • #10: Image source: https://morioh.com/a/18b4d4b4b161/python-data-structures-linked-list