Code Challenge Loops: Odd Indices


I have been going through the loop challenges and I need some clarification on how the range function is used in the answer. I don’t understand why we have 1 and 2 at the beginning and end. And what this bit of code actually means.

#Write your function here

def odd_indices(lst):

new_list =

for index in range(1, len(lst), 2):


return new_list

#Uncomment the line below when your function is done

print(odd_indices([4, 3, 7, 10, 11, -2]))

You consult document to see what these parameters are:

which shows:

range(start, stop[, step])


start = 1
stop = len(lst)
step = 2

Thank you I was getting confused now it seems really obvious

But why where you not able to use google to find the right documentation to answer this question yourself? Something to think about for next time :slight_smile:

because i thought this forum was there to help people that have questions…

Absolutely true :slight_smile: But learning to find answers/documentation which could help you is also a vital skill as developer :slight_smile:

I didn’t mean to discourage you from asking questions.

1 Like