How to implement list access by python
This article mainly introduces python how to achieve list access, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
1. Directly access the element through the index. The element range is [0, list length-1]. If it is exceeded, an exception is thrown and the current access value is returned.
Visit1 = [1,2,3,4,5,6,7,8,9,0] print (visit1 [0]) # 1
2. Index () gets the index position where the specified element appears for the first time in the list.
Visit2 = ["sss", "a", "b", "c"] print (visit2.index ("sss")) # 0print (visit2.index ("b", 2)) # 2 Thank you for reading this article carefully. I hope the article "how to achieve list access in python" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!