0% found this document useful (0 votes)
22 views1 page

Python List Functions

The document provides an overview of Python's built-in list functions, detailing their purpose and syntax. Functions include append, count, clear, extend, index, insert, len, pop, remove, reverse, and sort, each with a brief description and example. This serves as a quick reference for utilizing list operations in Python.

Uploaded by

venkatasai012345
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)
22 views1 page

Python List Functions

The document provides an overview of Python's built-in list functions, detailing their purpose and syntax. Functions include append, count, clear, extend, index, insert, len, pop, remove, reverse, and sort, each with a brief description and example. This serves as a quick reference for utilizing list operations in Python.

Uploaded by

venkatasai012345
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 Built-in List Functions

Function Description Syntax Example

append() Adds an element to the end of the list [Link](item) [1, 2].append(3) -> [1, 2, 3]

count() Counts occurrences of an element [Link](item) [1, 2, 2, 3].count(2) -> 2

clear() Removes all elements from the list [Link]() [1, 2, 3].clear() -> []

extend() Extends list with another iterable [Link](iterable) [1, 2].extend([3, 4]) -> [1, 2, 3, 4]

index() Returns index of first occurrence [Link](item) [1, 2, 3].index(2) -> 1

insert() Inserts element at index [Link](index, item) [1, 3].insert(1, 2) -> [1, 2, 3]

len() Returns number of elements len(list) len([1, 2, 3]) -> 3

pop() Removes and returns element at index [Link](index) [1, 2, 3].pop(1) -> 2, [1, 3]

remove() Removes first occurrence of item [Link](item) [1, 2, 3].remove(2) -> [1, 3]

reverse() Reverses the list in place [Link]() [1, 2, 3].reverse() -> [3, 2, 1]

sort() Sorts list in ascending order [Link]() [3, 1, 2].sort() -> [1, 2, 3]

You might also like