0% found this document useful (0 votes)
6 views7 pages

Python List Methods Overview

The document provides an overview of lists in Python, describing them as ordered, mutable collections that can hold different data types. It lists common methods for manipulating lists, including append(), insert(), remove(), pop(), sort(), reverse(), index(), count(), and extend(). Each method is briefly explained with examples demonstrating their usage.

Uploaded by

narsingojurishi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views7 pages

Python List Methods Overview

The document provides an overview of lists in Python, describing them as ordered, mutable collections that can hold different data types. It lists common methods for manipulating lists, including append(), insert(), remove(), pop(), sort(), reverse(), index(), count(), and extend(). Each method is briefly explained with examples demonstrating their usage.

Uploaded by

narsingojurishi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

List Methods in Python

-BY
24B81A05MB
Introduction to Lists:
[Link] are sequence data type
[Link] are ordered
[Link] collections of items in Python.
[Link] store elements of different data types.
[Link] using square brackets: e.g., my_list = [1, 2, 'apple', 4.5]
Common List Methods:
• append() – Add an element to the end of the list
my_list = [10, 20, 30]
my_l [Link](40) # [10, 20, 30, 40]

• insert() – Insert element at a specific index


my_list.insert(1, 15) # [10, 15, 20, 30, 40]

• remove() – Remove first matching element


my_list.remove(20) # [10, 15, 30, 40]

• pop() – Remove element at index (default last)


my_list.pop() # [10, 15, 30]
sort() – Sort the list
my_list.sort() # [10, 15, 30]

reverse() – Reverse the list order


my_list.reverse() # [30, 15, 10]

index()-Returns the position of the first occurrence of a specified value.


count():
Returns the number of times a value appears in the list.

extend():
Adds elements from another iterable (like a list) to the end of the current list.
TQ

You might also like