0% found this document useful (0 votes)
4 views2 pages

Python List Methods With Programs

The document provides an overview of various Python list methods, including their meanings and example programs. Key methods discussed include append(), extend(), insert(), remove(), pop(), clear(), index(), count(), sort(), and reverse(). Each method is explained with a brief description and a code snippet demonstrating its use.

Uploaded by

Varshitha Kn
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)
4 views2 pages

Python List Methods With Programs

The document provides an overview of various Python list methods, including their meanings and example programs. Key methods discussed include append(), extend(), insert(), remove(), pop(), clear(), index(), count(), sort(), and reverse(). Each method is explained with a brief description and a code snippet demonstrating its use.

Uploaded by

Varshitha Kn
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

Python List Methods with Meaning & Programs

append()
Meaning: Adds an element to the end of the list.

nums = [1, 2]
[Link](3)
print(nums)

extend()
Meaning: Adds elements of another list.

a = [1, 2]
b = [3, 4]
[Link](b)
print(a)

insert()
Meaning: Inserts element at a specific position.

nums = [1, 3]
[Link](1, 2)
print(nums)

remove()
Meaning: Removes a specified element.

nums = [1, 2, 3]
[Link](2)
print(nums)

pop()
Meaning: Removes and returns last element.

nums = [1, 2, 3]
[Link]()
print(nums)

clear()
Meaning: Removes all elements from list.

nums = [1, 2, 3]
[Link]()
print(nums)

index()
Meaning: Returns index of element.
nums = [10, 20, 30]
print([Link](20))

count()
Meaning: Counts number of occurrences.

nums = [1, 2, 2, 3]
print([Link](2))

sort()
Meaning: Sorts list in ascending order.

nums = [3, 1, 2]
[Link]()
print(nums)

reverse()
Meaning: Reverses the list.

nums = [1, 2, 3]
[Link]()
print(nums)

You might also like