Courseiva
Control Flow, Loops, Lists and LogiceasyMultiple SelectObjective-mapped

PCEP reversed() Practice Question

Which TWO of the following are valid ways to iterate over a list in reverse order? (Choose two.)

⚠ Common exam trap

A common trap is thinking that slicing with `[::-1]` is equivalent to `reversed()` for iteration. While both produce reverse order, slicing creates a new list, which may be memory-intensive and is not directly iterating over the original list. The exam often expects you to identify only the methods that iterate over the original list without creating a copy.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

for item in reversed(lst):

`reversed(lst)` returns an iterator that yields elements in reverse order without modifying the original list. Option B is correct because `range(len(lst)-1, -1, -1)` generates indices from the last to the first, allowing index-based access. These are the two valid methods according to the PCEP certification.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • for item in reversed(lst):

    Why this is correct

    Correct: `reversed(lst)` returns an iterator that yields elements in reverse order without copying the list.

  • for i in range(len(lst)-1, -1, -1):

    Why this is correct

    Correct: `range(len(lst)-1, -1, -1)` produces indices from the last to the first, allowing access to elements in reverse order.

  • for i in range(len(lst)):

    Why it's wrong here

    Incorrect: `range(len(lst))` generates indices 0 to len(lst)-1, which iterate forward, not reverse.

  • for item in lst[-1::-1]:

    Why it's wrong here

    Incorrect: Slicing `lst[-1::-1]` creates a new reversed list, which is not iterating over the original list in place.

  • for item in lst:

    Why it's wrong here

    Incorrect: Iterating over `lst` directly visits elements in their original forward order.

About these practice questions

One of 498 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.