Sometimes, while working with Python lists, we can have a problem in which we wish to find Even elements. This task can occur in many domains such as web development and while working with Databases. We might sometimes, require to just find the indices of them. Let’s discuss certain way to find indices of Even elements.

**Method #1 : Using loop**

This is brute force method in which this task can be performed. In this, we check for even element in list and append its index accordingly.

`# Python3 code to demonstrate working of ` `# Even Elements indices ` `# using loop ` ` ` `# initialize list ` `test_list ` `=` `[` `5` `, ` `6` `, ` `10` `, ` `4` `, ` `7` `, ` `1` `, ` `19` `] ` ` ` `# printing original list ` `print` `(` `"The original list is : "` `+` `str` `(test_list)) ` ` ` `# Even Elements indices ` `# using loop ` `res ` `=` `[] ` `for` `idx, ele ` `in` `enumerate` `(test_list): ` ` ` `if` `ele ` `%` `2` `=` `=` `0` `: ` ` ` `res.append(idx) ` ` ` `# printing result ` `print` `(` `"Indices list Even elements is : "` `+` `str` `(res)) ` |

*chevron_right*

*filter_none*

**Output :**

The original list is : [5, 6, 10, 4, 7, 1, 19] Indices list Even elements is : [1, 2, 3]

**Method #2 : Using list comprehension**

This is the shorthand by which this task can be performed. This method works in similar way as the above method. The difference is that it’s a one liner.

`# Python3 code to demonstrate working of ` `# Even Elements indices ` `# using list comprehension ` ` ` `# initialize list ` `test_list ` `=` `[` `5` `, ` `6` `, ` `10` `, ` `4` `, ` `7` `, ` `1` `, ` `19` `] ` ` ` `# printing original list ` `print` `(` `"The original list is : "` `+` `str` `(test_list)) ` ` ` `# Even Elements indices ` `# using list comprehension ` `res ` `=` `[idx ` `for` `idx, ele ` `in` `enumerate` `(test_list) ` `if` `ele ` `%` `2` `=` `=` `0` `] ` ` ` `# printing result ` `print` `(` `"Indices list Even elements is : "` `+` `str` `(res)) ` |

*chevron_right*

*filter_none*

**Output :**

The original list is : [5, 6, 10, 4, 7, 1, 19] Indices list Even elements is : [1, 2, 3]

Attention geek! Strengthen your foundations with the **Python Programming Foundation** Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the **Python DS** Course.

## Recommended Posts:

- Python program to get the indices of each element of one list in another list
- Python | Indices of sorted list of list elements
- Python | Get indices of True values in a binary list
- Python | Indices list of matching element from other list
- Python | Group elements at same indices in a multi-list
- Python | Find elements of a list by indices
- Python | Indices of N largest elements in list
- Python - Indices of atmost K elements in list
- Python - Remove elements at Indices in List
- Python | Get match indices
- How to get the indices of the sorted array using NumPy in Python?
- Python - Get the indices of Uppercase characters in given string
- Python - Get Even indexed elements in Tuple
- Python | Ways to find indices of value in list
- Python | Find indices with None values in given list
- Python program to fetch the indices of true values in a Boolean list
- Python | Duplicate element indices in list
- Python - Find the Maximum of Similar Indices in two list of Tuples
- Python - False indices in a boolean list
- Python | K Divided Indices List

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.