- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to print the elements of an array present on odd position
When it is required to print the elements of a list that is present in odd index/position, a loop can be used to iterate over the elements, and only check the odd positions in the list by specifying the step size as 2 in the range function.
Below is a demonstration of the same −
Example
my_list = [31, 42, 13, 34, 85, 0, 99, 1, 3] print("The list is :") print(my_list) print("The elements in odd positions are : ") for i in range(1, len(my_list), 2): print(my_list[i])
Output
The list is : [31, 42, 13, 34, 85, 0, 99, 1, 3] The elements in odd positions are : 42 34 0 1
Explanation
A list is defined, and is displayed on the console.
The list is iterated over beginning from the second index element, and the step size is mentioned as 2 in the range method.
Those elements that are in odd positions are displayed on the console.
- Related Articles
- Python program to print the elements of an array present on even position
- Python program to print the duplicate elements of an array
- Python program to print the elements of an array in reverse order
- Java program to Print Odd and Even Number from an Array
- Python program to print all distinct elements of a given integer array.
- Python program to left rotate the elements of an array
- Python program to right rotate the elements of an array
- Python program to print odd numbers in a list
- Python program to sort the elements of an array in ascending order
- Python program to sort the elements of an array in descending order
- Python program to print all odd numbers in a range
- Program to print Sum Triangle of an array.
- Program to reverse an array up to a given position in Python
- Golang Program to find the odd-occurring elements in a given array
- Python program to print sorted number formed by merging all elements in array

Advertisements