T = [L[i] for i in Idx]
Answer from van on Stack OverflowW3Schools
w3schools.com › python › ref_list_index.asp
Python List index() Method
Python DSA Lists and Arrays Stacks Queues Linked Lists Hash Tables Trees Binary Trees Binary Search Trees AVL Trees Graphs Linear Search Binary Search Bubble Sort Selection Sort Insertion Sort Quick Sort Counting Sort Radix Sort Merge Sort
GeeksforGeeks
geeksforgeeks.org › python › python-list-index
Python List index() - Find Index of Item - GeeksforGeeks
index() method in Python is a helpful tool when you want to find the position of a specific item in a list. It works by searching through the list from the beginning and returning the index (position) of the first occurrence of the element you're ...
Published April 27, 2025
Videos
01:33
#69 Index Method in Python – Find an Element’s Position in a List!
Python List index() method - Syntax & Examples - Find index ...
13:07
How to Find the Index of an Element in a List in Python? - YouTube
16:51
How to Access Lists in Python (Indexing & Slicing Explained) | ...
04:46
How To Get All Indices Of An Element In A List In Python - YouTube
07:28
Indexing and Slicing Python Lists for Beginners - YouTube
DataCamp
datacamp.com › tutorial › python-list-index
Python List index() Method Explained with Examples | DataCamp
March 28, 2025 - Learn how to use Python's index() function to find the position of elements in lists. Includes examples, error handling, and tips for beginners.
Top answer 1 of 8
351
T = [L[i] for i in Idx]
2 of 8
57
If you are using numpy, you can perform extended slicing like that:
>>> import numpy
>>> a=numpy.array(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
>>> Idx = [0, 3, 7]
>>> a[Idx]
array(['a', 'd', 'h'],
dtype='|S1')
...and is probably much faster (if performance is enough of a concern to to bother with the numpy import)
Reddit
reddit.com › r/learnpython › embarrassingly, i don't understand how list indexing works
r/learnpython on Reddit: Embarrassingly, i don't understand how list indexing works
August 31, 2024 -
I'm learning data structure and algorithms and i came across a question in the list section. i thought after i had understood python, i had understood list but a question was asked and i find myself finding it hard to understand how the list indexing works.
here's the sample code:
arr = [1, 2, 3, 4, 5, 6]
for i in range(1, 6):
arr[i - 1] = arr[i]
for i in range(0, 6):
print(arr[i], end = " ")
it looks simple to understand but, i just can't understand it.
Top answer 1 of 5
25
Let us step back a little. Before understanding your example, try to grok the example below for i in range(0, 3): print(i) which results in: 0 1 2 And the example below my_list = [42, 6, 2024] for i in range(0, 3): print(i, my_list[i]) Which results in: 0 42 1 6 2 2024 Are those clear to ya? Thanks!
2 of 5
10
What don't you understand?
Codecademy
codecademy.com › learn › dacp-python-fundamentals › modules › dscp-python-lists › cheatsheet
Python Fundamentals: Python Lists Cheatsheet | Codecademy
Python list elements are ordered by index, a number referring to their placement in the list. List indices start at 0 and increment by one.
Python.org
discuss.python.org › python help
Ho to solve: list indices must be integers or slices, not list - Python Help - Discussions on Python.org
March 15, 2021 - Hi guys! I’ve found this issue: Here is my code, I have two lists and a list that contains the two lists (my real lists are more complex but I’m trying to simplify them in order to focus on the main problem) a=[[1,2,3],[1,4,5]] b=[[3,5,7,8],[4,5,6,2]] list=[a,b] for i in list: for j in list[i]: …ecc, ecc…
Programiz
programiz.com › python-programming › methods › list › index
Python List index()
Become a certified Python programmer. Try Programiz PRO! ... The index() method returns the index of the specified element in the list.
ReqBin
reqbin.com › code › python › h54arbqc › python-list-index-example
How do I find the index of an element in a Python list?
In Python, list indexes start at 0. You can also check if an element exists in a list using the "in" operator. In this Python List Index example, we get the index of a list item using the list.index() method.
CodeWithHarry
codewithharry.com › tutorial › python-list-indexes
List Indexes | Python Tutorial | CodeWithHarry
Each item/element in a list has its own unique index. This index can be used to access any particular item from the list.
Kochiva
kochiva.com › home › python list index( ) method – explained with practical examples
Python List Index() Method - Explained with Practical Examples
September 26, 2024 - It returns the position or name of the student who has scored the 3rd highest marks. So, instead of going through the entire list to manually find out who has scored the 3rd highest marks, you just use a simple index function to get results in seconds. Informative article: What is Python | Python Programming Language
GeeksforGeeks
geeksforgeeks.org › python › python-accessing-all-elements-at-given-list-of-indexes
Accessing all elements at given list of indexes-Python - GeeksforGeeks
April 28, 2025 - Explanation: map() function with lambda i: a[i] retrieves elements from list a at the indexes specified in list b and stores them in res. itemgetter() is a neat way from Python’s operator module to fetch multiple elements at once by index.