Iterate with Enumerate
In Iterate with Enumerate, you receive a list of items and a target string, then return all indices where that target appears. The point of the exercise is not just matching values, but practicing Python?s enumerate() so you can read index and value together in one clean loop.
A simple approach is to scan the list once, collect index positions whenever the current element equals the target, and return that index list at the end. If the target does not appear, return an empty list. If it appears many times, include every matching index in ascending order based on original traversal.
The judge checks common patterns: repeated matches, no matches, empty input, and single-item input. So your result must be stable and exactly ordered as encountered. Keep the function side-effect free and return only the index list, because the checker compares structure and values directly. This problem is great for building everyday loop clarity: concise code, clear intent, and no extra complexity beyond accurate index tracking.
Algorithm Flow

Best Answers
def find_element_indices(items, target):
# Approach 1: Highly Pythonic List Comprehension with enumerate()
return [index for index, item in enumerate(items) if item == target]Comments (0)
Join the Discussion
Share your thoughts, ask questions, or help others with this problem.
