List Operations
Syntax of list
#Syntax : list[ start : end : step ]myList = [1, 2, 3, 4, 5, 6, 7, 8, 9]
#index 0 1 2 3 4 5 6 7 8
# -9 -8 -7 -6 -5 -4 -3 -2 -1List Operations
1. List Slicing
print('Original List:',myList)
print('First Element:',myList[0]) #Prints the first element of the list or 0th index of the list
print('Element at 3rd Index position:',myList[2]) #Prints the 3rd element of the list
print('Elements from 0th Index to 4th Index:',myList[0: 5]) #Prints elements of the list from 0th index to 4th index. IT DOESN'T INCLUDE THE LAST INDEX
print('Element at -7th Index:',myList[-7]) #Prints the -7th or 3rd element of the list2. Append Element to List
3. Index Element
4. Sort List
5. Pop Last Element
6. Remove Element
7. Insert Element
8. Count Element
9. Extend List
10. Reverse List

Last updated