![]() |
| Python List Data Type Complete Guide with Including Functions Examples |
List Definition in Python
Python List: List is a collection of data of different data type. It is used to store list of values. A list is created by putting list of comma-separated values between square brackets. A list in Python is an ordered, mutable (changeable) collection of items. Lists can store elements of different data types. List is a collection which is ordered and changeable. List is a allows duplicate members.
List All Functions in Python
| Len Function: It can be used to get the length numbers of elements in list. |
| Max Function: It can be used to get maximum value from the list. In case of string focus on ASCII value of first letter of list items. |
| Min Function: It can be used to get the minimum value from the list. |
| Append Function: It can be used to add the new item at the end of the list. |
| count Function: It can be used counts the number of occurrence of particular item in a list. |
| Copy Function: It can be used to copy the elements of one list into another list. |
| Extend Function: It can be used to join two list in a single list. |
| Index Function: It can be used to get the index value of particular list items. |
| Insert Function: It can be used to insert new value into list a particular index. |
| Pop Function: It can be used to delete the item of given index value. It delete last item if we do not pass index value. |
| Remove Function: It can be used to remove particular value from the list. |
| Reverse Function: It can be used to reverse list items. |
| Sort Function: It can be used sort list items we can display all list items in ascending order or descending order. |
How to Create List in Python
int_list=[15,25,36,84,59] float_list=[22.32,51.6,12.4,93.6] mixed_list=["Jiocoding",2026,46.3] print("String List:",str_list) print("Integer List:",int_list) print("Float List:",float_list) print("Mixed List:",mixed_list) print(type(str_list)) print(type(int_list)) print(type(float_list)) print(type(mixed_list)) ============OUTPUT============ String List: ['Hello', 'World', 'Python', 'Programming', 'jiocoding'] Integer List: [15, 25, 36, 84, 59] Float List: [22.32, 51.6, 12.4, 93.6] Mixed List: ['Jiocoding', 2026, 46.3] <class 'list'> <class 'list'> <class 'list'> <class 'list'> |
How to Access List Items in Python
Value of list can be accessed using index number. Index number is always an integer value and starts with 0.
Access List Elements in Python
print("Python List Data is:",data[0]) print("Programming Language:",data[1]) print("Webiste Name is:",data[2]) ============OUTPUT============ Python List Data is: Programming Programming Language: Python Website Name is: jiocoding |
Access List item by index Python
print("Data Access using Indexing") print("Data is:",data[1:6]) print("Data is:",data[::2]) ============OUTPUT============ Data Access using Indexing Data is: [10, 15, 20, 25, 30] Data is: [5, 15, 25, 35, 45] |
Access Value of List Using Negative Index
Access the list items using negative index number indexes start from the end of the list. Negative index always starts with [-1].
data=["Python","Programming","jiocoding"] here index of jiocoding [-1] ,Programming [-2] and Python[-3].
Example of List items Negative index
print("First element:",data[-1]) print("Second element:",data[-2]) print("Last element:",data[-3]) ============OUTPUT============ First element: jiocoding Second element: Programming Last element: Python |
List Slicing in Python Definition
Example of Slicing in Python
print("First element:",data[1:3]) print("Second element:",data[::2]) print("Last element:",data[1::3]) ============OUTPUT============ First element: ['Programming', 'jiocoding'] Second element: ['Python', 'jiocoding'] Last element: ['Programming'] |
How to Access List Elements in Python using for Loop
for name in names: print("Student Name is:",name) ============OUTPUT============ Student Name is: Ramesh Student Name is: Suresh Student Name is: Mahesh Student Name is: Naresh Student Name is: Rajesh |
Update List Items using index in Python
print("Before update List Data is") print(names) names[1]="Jiocoding" print("After update List Data is") print(names) ============OUTPUT============ Before update List Data is ['Ramesh', 'Suresh', 'Mahesh', 'Naresh', 'Rajesh'] After update List Data is ['Ramesh', 'Jiocoding', 'Mahesh', 'Naresh', 'Rajesh'] |
List Length Function in Python
Len Function: It can be used to get the length total numbers of elements in list. Length function is a built in or user define that counts mamy items are present in our list data.Example of len function in Python
print("Length of List Data:",len(data)) ============OUTPUT============ Length of List Data:5 |
List Max Function in Python
Max Function: It can be used to get maximum value from the list. In case of string focus on ASCII value of First letter of list items. The max function returns the largest value given out list data. Single iterable argument return its biggest item. The default keyword-only argument specifies an object to return if
the provided iterable is empty. With two or more positional arguments return the largest argument.
Example of max function in Python
print("Maximum Value of List Data:",max(data)) ============OUTPUT============ Maximum Value of List Data:99 |
List Min Function in Python
Min Function: It can be used to get the minimum value from the list. Minimum function are returns the smallest value from a out list data.
Example of min function in Python
print("Minimum Value of List Data:",min(data)) ============OUTPUT============ Minimum Value of List Data:12 |
List Append Function in Python
Append Function: It can be used to add the new item at the end of the list. The append function to add a new item to end position.
Example of append list in Python
print("Before Append Item insertion") print(data) data.append("Jiocoding") print("After Append Item insertion") print(data) ============OUTPUT============ Before Append Item insertion ['Python', 'Language', 'India', 'Bharat'] After Append Item insertion ['Python', 'Language', 'India', 'Bharat', 'Jiocoding'] |
List insert method in Python
insert Function(): insert function can be used to add new items into list at particular index.
Example of List insert Method in python
print("Before insert Item insertion") print(data) data.insert(2,"Jiocoding") print("After insert Item insertion") print(data) ============OUTPUT============ Before insert Item insertion ['Python', 'Language', 'India', 'Bharat'] After insert Item insertion ['Python', 'Language', 'Jiocoding', 'India', 'Bharat'] |
List remove function in Python
Remove Function(): The Remove function can be used to delete or remove item from list.
Example of remove function in Python
print("Before Delete List Item Data") print(data) data.remove("Bharat") print("After Delete List Item Data") print(data) ============OUTPUT============ Before Delete List Item Data ['Python', 'Language', 'India', 'Bharat'] After Delete List Item Data ['Python', 'Language', 'India'] |
Remove list item python by Pop
pop() function is used to delete or remove item from list using index. Pop() function will delete last item if we do not pass index.
Remove list element using Pop in Python
print("Before Delete List Data") print(data) data.pop(2) print("After Delete List Item Data") print(data) ============OUTPUT============ Before Delete List Items ['Python', 'Language', 'India', 'Bharat'] After Delete List Item ['Python', 'Language', 'Bharat'] |
Remove list Item using Pop in Python
print("Before Delete List Data") print(data) data.pop() print("After Delete List Item Data") print(data) ============OUTPUT============ Before Delete List Items ['Python', 'Language', 'India', 'Bharat'] After Delete List Item ['Python', 'Language', 'India'] |
List Delete Function in Python
Del Method: del keyword is also used to delete item using index number. Del keyword is also used to delete all the items of list.
Remove list element using del Keyword Python
print("Before Delete List Data") print(data) del data[2] print("After Delete List Item Data") print(data) ============OUTPUT============ Before Delete List Items ['Python', 'Language', 'India', 'Bharat'] After Delete List Item ['Python', 'Language', 'Bharat'] |
Delete Complete Data using del Keyword Python
print("Before Delete List Data") print(data) del data print("After Delete List Item Data") print(data) ============OUTPUT============ Before Delete List Data ['Python', 'Language', 'India', 'Bharat'] After Delete List Data NameError: name 'data' is not defined |
List Clear Function in Python
Clear Function: Clear() function is used to clear or empty the list items. It can be used to remove all elements from a list.
Example of empty list in Python
print("Before Clear List Items") print(data) data.clear() print("After Clear List Items") print(data) ============OUTPUT============ Before Clear List Items ['Python', 'Language', 'India', 'Bharat'] After Clear List Items [] |
Join List Elements in Python: Join Two List Join two lists using + symbol. We can join two list using plus(+) operator.
Join Two List Python
data2=["Welcome","Jiocoding","ListData"] data3=data1+data2 print(data3) ============OUTPUT============ ['Python', 'Language', 'India', 'Bharat', 'Welcome', 'Jiocoding', 'ListData'] |
Join items in List Python: Join two lists using extend function extend() function is also used to join two list.
Join Two List Python
data2=["Welcome","Jiocoding","ListData"] data1.extend(data2) print(data1) ============OUTPUT============ ['Python', 'Language', 'India', 'Bharat', 'Welcome', 'Jiocoding', 'ListData'] |
Join List Using Append: Join two lists using append function append() function is also used to join two list.
Join Two List Python
data2=["Welcome","Jiocoding","ListData"] for data in data2: data1.append(data) print(data1) ============OUTPUT============ ['Python', 'Language', 'India', 'Bharat', 'Welcome', 'Jiocoding', 'ListData'] |
Convert Tuple to List Python
It is used to convert sequence types (tuple) into list.
Convert Tuple to List Python
print("Tuple Data Items") print(tdata) print(type(tdata)) ldata=list(tdata) print("List Data Items") print(ldata) print(type(ldata)) ============OUTPUT============ Tuple Data Items ('Jiocoding', 'Python', 'Language', 'India', 'Bharat') <class 'tuple'> ['Jiocoding', 'Python', 'Language', 'India', 'Bharat'] <class 'list'> |
Count Function: This method counts the number of occurrence of particular item in a list.
Count List Items in Python
print(data) print("Total Counts:",data.count(40)) ============OUTPUT============ [10, 20, 40, 10, 16, 40, 50, 60, 40, 16, 30, 16, 10, 50] Total Counts: 3 |
List Copy Function in Python
Copy Function: This function copies the elements of one list into another.
Example of Count Method in Python
print("Before Copy Data List Items") print(data1) data2=data1.copy() print("After Copy Data2") print(data2) ============OUTPUT============ Before Copy Data List Items ['Jiocoding', 'Python', 'Language', 'India', 'Bharat'] After Copy Data2 ['Jiocoding', 'Python', 'Language', 'India', 'Bharat'] |
Index Function: It returns the lowest index of given element.
Example of Index Function in Python
print("Find Index Value of 50:",data.index(50)) ============OUTPUT============ Find Index Value of 50: 6 |
Sort Function: This function Sorts the list. By using this function we can display the list items in ascending order or descending order.
Example of Sort List Items in Python
print("Before Sort List Items") print(data) data.sort() print("After Sort List Items") print(data) ============OUTPUT============ Before Sort List Items [10, 20, 40, 10, 16, 40, 50, 60, 40, 16, 30, 16, 10, 50] After Sort List Items [10, 10, 10, 16, 16, 16, 20, 30, 40, 40, 40, 50, 50, 60] |
Ascending order Descending order in Python
print("Before Descending Order List Items") print(data) data.sort(reverse=True) print("After Descending Order List Items") print(data) ============OUTPUT============ Before Descending Order List Items [10, 20, 40, 10, 16, 40, 50, 60, 40, 16, 30, 16, 10, 50] After Descending Order List Items [60, 50, 50, 40, 40, 40, 30, 20, 16, 16, 16, 10, 10, 10] |

