Question: If we have a valid non - empty list, lst , but we wish only to iterate over the odd - indexed elements, which of

If we have a valid non-empty list, lst, but we wish only to iterate over the odd-indexed elements, which of the following is the best approach?
Question 19 options:
Iterate through the entire list, keep a counter, and check to see if the counter is even or odd, and then perform the desired operation with the odd-indexed elements.
Use for i in range(1, len(lst),2) to step through the odd indexed elements, and then use lst[i] within the body of the loop.
Use a while loop with a counter.
Use for e in lst if i %2==1.
None of the above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!