-5

I'm trying to iterate over a list using enumerator in Python, but I want to display only those element that are at odd index of the list. Please note that I do not wish to use the standard step of dividing and checking remainder by 2

2 Answers2

0
a = range(1,10)
for x, y in enumerate(a):
     if not (x % 2):
         print(y)

edit: downvotes? that's not very nice, y'all

keen
  • 19
  • 4
0
for i, item in enumerate(list_name[1::2]):...
Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35