SlideShare a Scribd company logo
1 of 15
PYTHON LIST
By A. A. Bhumkar
PYTHON LIST
1).Python lists are the data structure that is capable of
holding different type of data.
2).Python lists are mutable i.e., Python will not create a
new list if we modify an element in the list.
3).It is a container that holds other objects in a given order.
Different operation like insertion and deletion can be
performed on lists.
4).A list can be composed by storing a sequence of
different type of values separated by commas.
5).A python list is enclosed between square([]) brackets.
6).The elements are stored in the index basis with starting
index as 0.
CREATING LIST
 A list can be created by putting the value inside the
square bracket and separated by comma.
 Syntax:
<list_name>=[value1,value2,value3,...,valuen];
 For accessing list :
<list_name>[index]
ELEMENTS IN A LISTS:
Data=[1,2,3,4,5];
LIST OPERATIONS:
a) Adding Lists:
Lists can be added by using the concatenation operator(+)
to join two lists.
Eg:
list1=[10,20]
list2=[30,40]
list3=list1+list2
print list3 Output:
>>>
[10, 20, 30, 40]
>>>
b) Replicating lists:
Replicating means repeating . It can be performed by
using '*' operator by a specific number of time.
Eg:
list1=[10,20]
print list1*1
Output:
>>>
[10, 20]
>>>
c) List slicing:
A subpart of a list can be retrieved on the basis of index.
This subpart is known as list slice.
Eg:
list1=[1,2,4,5,7]
print list1[0:2]
print list1[4]
list1[1]=9
print list1
Output:
>>>
[1, 2]
7
[1, 9, 4, 5, 7]
>>>
OTHER OPERATIONS:
a) Updating elements in a List:
To update or change the value of particular index of a list,
assign the value to that particular index of the List.
Syntax:
<list_name>[index]=<value>
Eg.
>>> list=[1,2,3,4]
>>> list[2]="Hello Python"
>>> print(list)
[1, 2, 'Hello Python', 4]
>>>
b) Appending elements to a List:
append() method is used to append i.e., add an element at
the end of the existing elements.
Syntax:
<list_name>.append(item)
Eg.
>>> list=[1,2,3,4]
>>> list.append(40)
>>> print(list)
[1, 2, 3, 4, 40]
>>>
c) Deleting Elements from a List:
del statement can be used to delete an element from the
list. It can also be used to delete all items from
startIndex to endIndex.
Eg.
>>> list = [1,2,3,4]
>>> del list[2]
>>> print(list)
[1, 2, 4]
FUNCTIONS AND METHODS OF LISTS:
Function Description Example
min(list)
Returns the minimum
value from the list
given.
>>> list=[1,2,3,4,5]
>>> min(list)
1
max(list)
Returns the largest
value from the given
list.
>>> list=[1,2,3,4,5]
>>> max(list)
5
len(list)
Returns number of
elements in a list.
>>> list=[1,2,3,4,5]
>>> len(list)
5
Methods Description Example
index(object)
Returns the index value of the
object.
>>> l = ['a','b','c','d']
>>>l.index(‘a’)
>>>0
count(object)
It returns the number of times an
object is repeated in list.
>>> l = [1,2,3,1,4,5,1]
>>> l.count(1)
3
pop()/pop(index)
Returns the last object or the
specified indexed object. It
removes the popped object.
>>> l = [1,2,3,1,4,5,1]
>>> l.pop()
1
>>> print(list)
[1, 2, 3, 4, 5]
>>> l.pop(3)
1
>>> print(l)
[1, 2, 3, 4, 5]
Methods Description Example
insert(index,object)
Insert an object at the
given index.
>>>l=[1,2,3,4,5]
>>> l.insert(3,11)
>>> print(l)
[1, 2, 3, 11, 4, 5]
extend(sequence)
It adds the sequence to
existing list.
>>>l=[1, 2, 3, 11, 4, 5]
>>> seq = (12,13)
>>> l.extend(seq)
>>> print(l)
[1, 2, 3, 11, 4, 5, 12, 13]
remove(object)
It removes the object
from the given List.
>>>l=[1, 2, 3, 11, 4, 5, 12,
13]
>>> l.remove(12)
>>> print(l)
[1, 2, 3, 11, 4, 5, 13]
Methods Description
Example
reverse()
Reverse the position of all the
elements of a list.
>>>l=[1, 2, 3, 11, 4, 5, 13]
>>> l.reverse()
>>> print(l)
[13, 5, 4, 11, 3, 2, 1]
sort()
It is used to sort the elements
of the List.
>>> l = [2,4,1,5,3]
>>> l.sort()
>>> print(l)
[1, 2, 3, 4, 5]
THANK YOU !!!

More Related Content

What's hot (20)

Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
 
Presentation on the topic selection sort
Presentation on the topic selection sortPresentation on the topic selection sort
Presentation on the topic selection sort
 
Linked list
Linked listLinked list
Linked list
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
 
Python set
Python setPython set
Python set
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Data Structure and Algorithms Linked List
Data Structure and Algorithms Linked ListData Structure and Algorithms Linked List
Data Structure and Algorithms Linked List
 
Linked list
Linked listLinked list
Linked list
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structure
 
Tuples in Python
Tuples in PythonTuples in Python
Tuples in Python
 
8 python data structure-1
8 python data structure-18 python data structure-1
8 python data structure-1
 
Priority Queue in Data Structure
Priority Queue in Data StructurePriority Queue in Data Structure
Priority Queue in Data Structure
 
Quick sort
Quick sortQuick sort
Quick sort
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
Linked List
Linked ListLinked List
Linked List
 
Queues
QueuesQueues
Queues
 
Array linear data_structure_2 (1)
Array linear data_structure_2 (1)Array linear data_structure_2 (1)
Array linear data_structure_2 (1)
 

Similar to Python list

Python List.ppt
Python List.pptPython List.ppt
Python List.pptT PRIYA
 
Lecture2.pptx
Lecture2.pptxLecture2.pptx
Lecture2.pptxSakith1
 
lists_list_of_liststuples_of_python.pptx
lists_list_of_liststuples_of_python.pptxlists_list_of_liststuples_of_python.pptx
lists_list_of_liststuples_of_python.pptxShanthiJeyabal
 
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 184Mahmoud Samir Fayed
 
Data type list_methods_in_python
Data type list_methods_in_pythonData type list_methods_in_python
Data type list_methods_in_pythondeepalishinkar1
 
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 210Mahmoud Samir Fayed
 
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 202Mahmoud Samir Fayed
 
Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfMCCMOTOR
 
Python list concept
Python list conceptPython list concept
Python list conceptDrJSaiGeetha
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212Mahmoud Samir Fayed
 
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.pdfAsst.prof M.Gokilavani
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdfAshaWankar1
 
lists8.pptx of chapter 12 IP Basic Python
lists8.pptx of chapter 12 IP Basic Pythonlists8.pptx of chapter 12 IP Basic Python
lists8.pptx of chapter 12 IP Basic Pythonkvpv2023
 

Similar to Python list (20)

Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Python lists &amp; sets
Python lists &amp; setsPython lists &amp; sets
Python lists &amp; sets
 
Python List.ppt
Python List.pptPython List.ppt
Python List.ppt
 
Lecture2.pptx
Lecture2.pptxLecture2.pptx
Lecture2.pptx
 
lists_list_of_liststuples_of_python.pptx
lists_list_of_liststuples_of_python.pptxlists_list_of_liststuples_of_python.pptx
lists_list_of_liststuples_of_python.pptx
 
Module III.pdf
Module III.pdfModule III.pdf
Module III.pdf
 
Python lists
Python listsPython lists
Python lists
 
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 for Beginners(v3)
Python for Beginners(v3)Python for Beginners(v3)
Python for Beginners(v3)
 
Data type list_methods_in_python
Data type list_methods_in_pythonData type list_methods_in_python
Data type list_methods_in_python
 
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
 
Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
 
Python list concept
Python list conceptPython list concept
Python list concept
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212
 
updated_list.pptx
updated_list.pptxupdated_list.pptx
updated_list.pptx
 
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_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
 
lists8.pptx of chapter 12 IP Basic Python
lists8.pptx of chapter 12 IP Basic Pythonlists8.pptx of chapter 12 IP Basic Python
lists8.pptx of chapter 12 IP Basic Python
 
Module-2.pptx
Module-2.pptxModule-2.pptx
Module-2.pptx
 

Recently uploaded

Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

Python list

  • 1. PYTHON LIST By A. A. Bhumkar
  • 2. PYTHON LIST 1).Python lists are the data structure that is capable of holding different type of data. 2).Python lists are mutable i.e., Python will not create a new list if we modify an element in the list. 3).It is a container that holds other objects in a given order. Different operation like insertion and deletion can be performed on lists. 4).A list can be composed by storing a sequence of different type of values separated by commas. 5).A python list is enclosed between square([]) brackets. 6).The elements are stored in the index basis with starting index as 0.
  • 3. CREATING LIST  A list can be created by putting the value inside the square bracket and separated by comma.  Syntax: <list_name>=[value1,value2,value3,...,valuen];  For accessing list : <list_name>[index]
  • 4. ELEMENTS IN A LISTS: Data=[1,2,3,4,5];
  • 5. LIST OPERATIONS: a) Adding Lists: Lists can be added by using the concatenation operator(+) to join two lists. Eg: list1=[10,20] list2=[30,40] list3=list1+list2 print list3 Output: >>> [10, 20, 30, 40] >>>
  • 6. b) Replicating lists: Replicating means repeating . It can be performed by using '*' operator by a specific number of time. Eg: list1=[10,20] print list1*1 Output: >>> [10, 20] >>>
  • 7. c) List slicing: A subpart of a list can be retrieved on the basis of index. This subpart is known as list slice. Eg: list1=[1,2,4,5,7] print list1[0:2] print list1[4] list1[1]=9 print list1 Output: >>> [1, 2] 7 [1, 9, 4, 5, 7] >>>
  • 8. OTHER OPERATIONS: a) Updating elements in a List: To update or change the value of particular index of a list, assign the value to that particular index of the List. Syntax: <list_name>[index]=<value> Eg. >>> list=[1,2,3,4] >>> list[2]="Hello Python" >>> print(list) [1, 2, 'Hello Python', 4] >>>
  • 9. b) Appending elements to a List: append() method is used to append i.e., add an element at the end of the existing elements. Syntax: <list_name>.append(item) Eg. >>> list=[1,2,3,4] >>> list.append(40) >>> print(list) [1, 2, 3, 4, 40] >>>
  • 10. c) Deleting Elements from a List: del statement can be used to delete an element from the list. It can also be used to delete all items from startIndex to endIndex. Eg. >>> list = [1,2,3,4] >>> del list[2] >>> print(list) [1, 2, 4]
  • 11. FUNCTIONS AND METHODS OF LISTS: Function Description Example min(list) Returns the minimum value from the list given. >>> list=[1,2,3,4,5] >>> min(list) 1 max(list) Returns the largest value from the given list. >>> list=[1,2,3,4,5] >>> max(list) 5 len(list) Returns number of elements in a list. >>> list=[1,2,3,4,5] >>> len(list) 5
  • 12. Methods Description Example index(object) Returns the index value of the object. >>> l = ['a','b','c','d'] >>>l.index(‘a’) >>>0 count(object) It returns the number of times an object is repeated in list. >>> l = [1,2,3,1,4,5,1] >>> l.count(1) 3 pop()/pop(index) Returns the last object or the specified indexed object. It removes the popped object. >>> l = [1,2,3,1,4,5,1] >>> l.pop() 1 >>> print(list) [1, 2, 3, 4, 5] >>> l.pop(3) 1 >>> print(l) [1, 2, 3, 4, 5]
  • 13. Methods Description Example insert(index,object) Insert an object at the given index. >>>l=[1,2,3,4,5] >>> l.insert(3,11) >>> print(l) [1, 2, 3, 11, 4, 5] extend(sequence) It adds the sequence to existing list. >>>l=[1, 2, 3, 11, 4, 5] >>> seq = (12,13) >>> l.extend(seq) >>> print(l) [1, 2, 3, 11, 4, 5, 12, 13] remove(object) It removes the object from the given List. >>>l=[1, 2, 3, 11, 4, 5, 12, 13] >>> l.remove(12) >>> print(l) [1, 2, 3, 11, 4, 5, 13]
  • 14. Methods Description Example reverse() Reverse the position of all the elements of a list. >>>l=[1, 2, 3, 11, 4, 5, 13] >>> l.reverse() >>> print(l) [13, 5, 4, 11, 3, 2, 1] sort() It is used to sort the elements of the List. >>> l = [2,4,1,5,3] >>> l.sort() >>> print(l) [1, 2, 3, 4, 5]