Home >>Python Programs >Python program to print the elements of an array present on odd position
In this example, we will see a Python program through which we can print the elements of an array present on odd positions.
Odd position element can be found by traversing the given array and incrementing the value of i by 2. In this way the i will initialize with 0 and after incrementing it will be 2, 4, 6, 8, etc. because the array indexing starts with 0.
#Initialize array
arr = [9,10,11,12,13,14,15];
print("Elements of given array present on odd position: ");
#Loop through the array by incrementing the value of i by 2
#Here, i will start from 1 as first even positioned element is present at position 1.
for i in range(1, len(arr), 2):
print(arr[i]);