Python program to print array element present at even position

Amansingh Javatpoint
2 min readApr 7, 2021

Python program to print array element present at even position

In this program, we’ll see a Python program that prints the elements of an array that are in even positions. We can do this by iterating an array’s elements and incrementing the value of i by 2 till the last element of an array. Since array indexing begins with 0, i will be initialized with 1 and then incremented to 3, 5, 7, 9, and so on. After the complete iteration, the element presented at an even position will be printed.

Example:

Input: arr1 = [1, 2, 3, 4, 5]

Output = [2, 4]

Algorithm:

  • Declare and initialize an array and find the length of the array.
  • Iterates the array by initializing the variable’s value to 1 and increment the value of a variable by 2.
  • Print the element at even positions.

--

--