FUNCTION OF LIST
sort(): The sort() method is a built-in Python method that, by default, sorts
the list in ascending order. However, you’ll modify the order from
ascending to descending by specifying the sorting criteria.
Eg.
List=[111,112,114,121,122,124,118,119]
[Link]()
OUTPUT-[111, 112, 114, 118, 119, 121, 122, 124]
type(list): For the type() function, it returns the class type of an object
Eg.
List=[111,112,114,121,122,124,118,119]
type(List)
append():Used for appending and adding elements to List. It is used to
add elements to the last position of the List.
Eg.
List=[111,112,114,121,122,124,118,119]
[Link]([456,345,9809])
Output-[111, 112, 114, 121, 122, 124, 118, 119, [456, 345, 9809]]
extend(): The extend() method increases the length of the list by the
number of elements that are provided to the strategy, so if you’d prefer
to add multiple elements to the list, you will be able to use this method.
Eg.
FUNCTION OF LIST
List=[111,112,114,121,122,124,118,119]
[Link]([453,333,333,478])
print(List)
output-[111, 112, 114, 121, 122, 124, 118, 119, 453, 333, 333, 478]
index(): Returns the first appearance of a particular value.
Eg.
List=[111,112,114,121,122,124,118,119]
[Link](114)
max(list): The max() function will return the highest value of the inputted
values
Eg.
List=[111,112,114,121,122,124,118,119]
max_list=max(List)
print(max_list)
output-124
min(list): The min() function will return the lowest value of the inputted
values.
Eg.
List=[111,112,114,121,122,124,118,119]
min_list=min(List
print(min_list)
output-111
FUNCTION OF LIST
len(list): The len() function shows the number of elements in a list.
Eg.
List=[111,112,114,121,122,124,118,119]
List2=[111,112,114,121,122,124,118,119,56,90,24]
print(len(List))
print(len(List2))
output-
11
clear(): Removes all the elements from the list.
List=[111,112,114,121,122,124,118,119]
Eg.
[Link]()
print(List)
output-[]
insert(): Inserts an element at the specified position. .
Eg.
List=[111,112,114,121,122,124,118,119]
[Link](5,[45,67,89])
print(List)
output-[111, 112, 114, 121, 122, [45, 67, 89], 124, 118, 119]
count(): Returns the number of elements with the required value.
Eg.
FUNCTION OF LIST
List=[111,112,114,121,122,124,118,119,119,111]
v=[Link](111)
print(v)
output-2
pop(): Removes the element at the required position.
Eg.
List=[111,112,114,121,122,124,118,119,119,111]
[Link](1)
print(List)
output-
[111, 114, 121, 122, 124, 118, 119, 119, 111]
remove(): Removes the primary item with the desired value.
Eg.
List=[111,112,114,121,122,124,118,119,119,111]
[Link](111)
print(List)
reverse(): Reverses the order of the list.
Eg.
List=[111,112,114,121,122,124,118,119,119]
[Link]()
print(List)
output-[119, 119, 118, 124, 122, 121, 114, 112, 111]
FUNCTION OF LIST
copy(): Returns a duplicate of the list.
List=[111,112,114,121,122,124,118,119,119,111]
list2=[Link]()
print(list2)
output-[111, 112, 114, 121, 122, 124, 118, 119, 119, 111]