SlideShare a Scribd company logo
1 of 16
T.Priya
Assistant Professor
 Lists are used to store multiple items or values in a single variable.
 The list is a sequence data type which is used to store the collection
of data. Tuples and String are other types of sequence data types
 Python list are mutable, ordered, changeable, and allow duplicate
values. we can change their elements after forming.
 Lists are one of 4 built-in data types the other 3 are Tuple, Set and
Dictionary, all with different qualities and usage.
 Lists are created using square brackets [ ] and separated by
commas.
 List items are indexed, the first item has index [0], the second item
has index [1] etc.
List Introduction:
Syntax:
list [iterable]
Example for python list:
>>> list=['a','b','c']
>>> print(list)
Output:
['a', 'b', 'c']
>>>
Example 2:
>>> list=[2,3,4,5,6]
>>> print(list)
O/P [2, 3, 4, 5, 6]
A list can contain different data types:
>>> list=["rakshita",2,"sweatha",1]
>>> print(list)
O/P ['rakshita', 2, 'sweatha', 1]
Access value in list:
There are different ways to accessing the list in python (index
and value)
Example (index value)
•
>>> list=["CS","CA","MSC"]
>>> print(list[0])
CS
>>> print(list[1])
CA
>>> print(list[2])
MSC
list.index() Return the index
value
Ex:
>>> list=["CS","CA","MSC"]
>>> list.index("CA")
O/P
1
Adding an item in the list:
append()  The append() method adds an item at the end of
the list.
>>> list.append("AI&DS")
>>> print(list)
O/P
['CS', 'CA', 'MSC', 'AI&DS']
Insert  The insert() method to add an element at the
specified index.
>>> list.insert(2,"MCA")
>>> print(list)
['CS', 'CA', 'MCA', 'MSC', 'AI&DS']
Nested List:
In order to create a nested list, you can simply use
square brackets [] to enclose one or more lists inside
another list.
Example 1:
>>>
list=[['cs','ca'],[2,4],[True,False]]
>>> print(list)
O/P
[['cs', 'ca'], [2, 4], [True, False]]
Example 2:
>>> list1=["cs","ca"]
>>> list2=["msc"]
>>> list3=[list1,list2]
>>> list3
O/P
[['cs', 'ca'], ['msc']]
Basic Operation in list & List Methods :
There are many different types of operations that
you can perform on Python lists, including:
1. Append 2. Insert 3. Length 4.Sort
5. Indexing 6. Delete 7. Pop 8. Concatenation
9. Reverse 10. Extend
1. Append:
The append() method adds an item at the end of the list.
Example:
>>> list=["CS","CA","MSC"]
>>> print(list)
O/P
['CS', 'CA', 'MSC']
>>> list.append("AI&DS")
>>> print(list)
O/P
['CS', 'CA', 'MSC', 'AI&DS']
2.Insert:
The insert() method to add an element at the specified
index.
Example:
>>> list=["CS","CA","MSC"]
>>> print(list)
O/P
['CS', 'CA', 'MSC']
>>> list.insert(2,"MCA")
>>> print(list)
O/P
['CS', 'CA', 'MCA', 'MSC']
3.Length:
Python len() is used to get the length of the list.
Example:
4. Sort:
The list elements can be sorted either ascending or descending.
Example:
>>> list=[]
>>> print(len(list))
O/P  0
>>> list=["CS","CA","MSC"]
>>> print(len(list))
O/P  3
>>>
a=["sweatha","priya","rakshita"]
>>> a.sort()
>>> print(a)
O/P
['priya', 'rakshita', 'sweatha']
5. Indexing:
index() is a built-in Python function that Return the index value.
Example:
6.Delete:
Using the remove function, we can easily delete a list element.
Example:
>>>list=["CS","CA","MSC"]
>>> list.index("CA")
O/P
1
>>>list=["CS","CA","MSC"]
>>> list.remove("CS")
>>> print(list)
O/P
['CA', 'MSC']
7. Pop:
The pop() function can also be used to delete and return a list
element (index value).
Example:
8. Concatenation:
Using the ‘+’ operator, we can easily concatenate two lists.
(Concatenation is equivalent to appending two lists).
Example:
>>>
a=["sweatha","priya","rakshita"]
>>> a.pop(1)
'priya'
>>> print(a)
O/P ['sweatha', 'rakshita']
>>> list1=["cs","ca"]
>>> list2=["msc","mca"]
>>> print(list1+list2)
O/P
['cs', 'ca', 'msc', 'mca']
9. Reverse:
Reverses the order of the elements in the list.
Example:
10. Extend:
Extend () method can be used to add more than one element at the
end of a list.
Example:
>>> list=['a','b','c','d']
>>> list.reverse()
>>> print(list)
O/P
['d', 'c', 'b', 'a']
>>> ss=['cs','ca']
>>> ss.extend(['msccs'])
>>> print(ss)
O/P
['cs', 'ca', 'msccs']
11. Max & Min:
The method used to find the minimum element in the list, and
the maximum element in the list.
Example:
>>> s1=[56,76,34,90,46]
>>> print(max(s1))
90
>>> s1=[56,76,34,90,46]
>>> print(min(s1))
34
Python List.ppt

More Related Content

What's hot (20)

NUMPY
NUMPY NUMPY
NUMPY
 
Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Python: Modules and Packages
Python: Modules and PackagesPython: Modules and Packages
Python: Modules and Packages
 
Collection Framework in java
Collection Framework in javaCollection Framework in java
Collection Framework in java
 
Dot net assembly
Dot net assemblyDot net assembly
Dot net assembly
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Map, Filter and Reduce In Python
Map, Filter and Reduce In PythonMap, Filter and Reduce In Python
Map, Filter and Reduce In Python
 
Python: Polymorphism
Python: PolymorphismPython: Polymorphism
Python: Polymorphism
 
Python : Functions
Python : FunctionsPython : Functions
Python : Functions
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Python Collections Tutorial | Edureka
Python Collections Tutorial | EdurekaPython Collections Tutorial | Edureka
Python Collections Tutorial | Edureka
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
 
Advanced Python : Decorators
Advanced Python : DecoratorsAdvanced Python : Decorators
Advanced Python : Decorators
 
Control Structures in Python
Control Structures in PythonControl Structures in Python
Control Structures in Python
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
String in python use of split method
String in python use of split methodString in python use of split method
String in python use of split method
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Nested class in java
Nested class in javaNested class in java
Nested class in java
 

Similar to Python List.ppt (20)

Python for Beginners(v3)
Python for Beginners(v3)Python for Beginners(v3)
Python for Beginners(v3)
 
Unit - 4.ppt
Unit - 4.pptUnit - 4.ppt
Unit - 4.ppt
 
Python lists
Python listsPython lists
Python lists
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
 
Python list
Python listPython list
Python list
 
Pytho lists
Pytho listsPytho lists
Pytho lists
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Python Lecture 8
Python Lecture 8Python Lecture 8
Python Lecture 8
 
Lecture2.pptx
Lecture2.pptxLecture2.pptx
Lecture2.pptx
 
updated_list.pptx
updated_list.pptxupdated_list.pptx
updated_list.pptx
 
8 python data structure-1
8 python data structure-18 python data structure-1
8 python data structure-1
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptx
 
List_tuple_dictionary.pptx
List_tuple_dictionary.pptxList_tuple_dictionary.pptx
List_tuple_dictionary.pptx
 
The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210
 
The Ring programming language version 1.8 book - Part 27 of 202
The Ring programming language version 1.8 book - Part 27 of 202The Ring programming language version 1.8 book - Part 27 of 202
The Ring programming language version 1.8 book - Part 27 of 202
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
Python data handling notes
Python data handling notesPython data handling notes
Python data handling notes
 
Python list
Python listPython list
Python list
 
The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdf
 

Recently uploaded

Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 

Python List.ppt

  • 2.  Lists are used to store multiple items or values in a single variable.  The list is a sequence data type which is used to store the collection of data. Tuples and String are other types of sequence data types  Python list are mutable, ordered, changeable, and allow duplicate values. we can change their elements after forming.  Lists are one of 4 built-in data types the other 3 are Tuple, Set and Dictionary, all with different qualities and usage.  Lists are created using square brackets [ ] and separated by commas.  List items are indexed, the first item has index [0], the second item has index [1] etc. List Introduction:
  • 3. Syntax: list [iterable] Example for python list: >>> list=['a','b','c'] >>> print(list) Output: ['a', 'b', 'c'] >>>
  • 4. Example 2: >>> list=[2,3,4,5,6] >>> print(list) O/P [2, 3, 4, 5, 6] A list can contain different data types: >>> list=["rakshita",2,"sweatha",1] >>> print(list) O/P ['rakshita', 2, 'sweatha', 1]
  • 5. Access value in list: There are different ways to accessing the list in python (index and value) Example (index value) • >>> list=["CS","CA","MSC"] >>> print(list[0]) CS >>> print(list[1]) CA >>> print(list[2]) MSC list.index() Return the index value Ex: >>> list=["CS","CA","MSC"] >>> list.index("CA") O/P 1
  • 6. Adding an item in the list: append()  The append() method adds an item at the end of the list. >>> list.append("AI&DS") >>> print(list) O/P ['CS', 'CA', 'MSC', 'AI&DS'] Insert  The insert() method to add an element at the specified index. >>> list.insert(2,"MCA") >>> print(list) ['CS', 'CA', 'MCA', 'MSC', 'AI&DS']
  • 7. Nested List: In order to create a nested list, you can simply use square brackets [] to enclose one or more lists inside another list. Example 1: >>> list=[['cs','ca'],[2,4],[True,False]] >>> print(list) O/P [['cs', 'ca'], [2, 4], [True, False]] Example 2: >>> list1=["cs","ca"] >>> list2=["msc"] >>> list3=[list1,list2] >>> list3 O/P [['cs', 'ca'], ['msc']]
  • 8. Basic Operation in list & List Methods : There are many different types of operations that you can perform on Python lists, including: 1. Append 2. Insert 3. Length 4.Sort 5. Indexing 6. Delete 7. Pop 8. Concatenation 9. Reverse 10. Extend
  • 9. 1. Append: The append() method adds an item at the end of the list. Example: >>> list=["CS","CA","MSC"] >>> print(list) O/P ['CS', 'CA', 'MSC'] >>> list.append("AI&DS") >>> print(list) O/P ['CS', 'CA', 'MSC', 'AI&DS']
  • 10. 2.Insert: The insert() method to add an element at the specified index. Example: >>> list=["CS","CA","MSC"] >>> print(list) O/P ['CS', 'CA', 'MSC'] >>> list.insert(2,"MCA") >>> print(list) O/P ['CS', 'CA', 'MCA', 'MSC']
  • 11. 3.Length: Python len() is used to get the length of the list. Example: 4. Sort: The list elements can be sorted either ascending or descending. Example: >>> list=[] >>> print(len(list)) O/P  0 >>> list=["CS","CA","MSC"] >>> print(len(list)) O/P  3 >>> a=["sweatha","priya","rakshita"] >>> a.sort() >>> print(a) O/P ['priya', 'rakshita', 'sweatha']
  • 12. 5. Indexing: index() is a built-in Python function that Return the index value. Example: 6.Delete: Using the remove function, we can easily delete a list element. Example: >>>list=["CS","CA","MSC"] >>> list.index("CA") O/P 1 >>>list=["CS","CA","MSC"] >>> list.remove("CS") >>> print(list) O/P ['CA', 'MSC']
  • 13. 7. Pop: The pop() function can also be used to delete and return a list element (index value). Example: 8. Concatenation: Using the ‘+’ operator, we can easily concatenate two lists. (Concatenation is equivalent to appending two lists). Example: >>> a=["sweatha","priya","rakshita"] >>> a.pop(1) 'priya' >>> print(a) O/P ['sweatha', 'rakshita'] >>> list1=["cs","ca"] >>> list2=["msc","mca"] >>> print(list1+list2) O/P ['cs', 'ca', 'msc', 'mca']
  • 14. 9. Reverse: Reverses the order of the elements in the list. Example: 10. Extend: Extend () method can be used to add more than one element at the end of a list. Example: >>> list=['a','b','c','d'] >>> list.reverse() >>> print(list) O/P ['d', 'c', 'b', 'a'] >>> ss=['cs','ca'] >>> ss.extend(['msccs']) >>> print(ss) O/P ['cs', 'ca', 'msccs']
  • 15. 11. Max & Min: The method used to find the minimum element in the list, and the maximum element in the list. Example: >>> s1=[56,76,34,90,46] >>> print(max(s1)) 90 >>> s1=[56,76,34,90,46] >>> print(min(s1)) 34