Sequence is the most basic data structure in Python. Each element in the sequence is assigned a number - its position, or index. The first index is 0, the second index is 1, and so on. Python has six built-in types of sequences, but the most common are lists and tuples. Today I would like to share with you two ways to find the location of elements in python list
1. Access a single element through index positioning, listname represents the name of the list, and index represents the index value of the element to be searched.
Grammatical structure
listname [index]
2. Access multiple elements by slicing, listname represents the name of the list, and index represents the index value of the element to be searched.
Grammatical structure
listname[ start : end :step]
example
list = [ 'Da Wei' , 'Xiao Wei' , 'Xiaowei' , one hundred and twenty-three ] print ( list [ zero ])
print ( list [ one : three ])
print ( list [ two :])