PCEP Computer Programming and Python Fundamentals Practice Question
A programmer wants to iterate over a list and also access the index. Which built-in function should they use?
⚠ Common exam trap
The PCEP exam often tests the distinction between `enumerate()` and `range(len())`, where candidates mistakenly think `range()` alone provides index access, but it only generates numbers and requires explicit indexing into the list.
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
✓
enumerate()
The `enumerate()` function is the correct choice because it returns an iterator that yields pairs of (index, element) for each item in an iterable, allowing direct access to both the index and the value during iteration without manually managing a counter.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
zip()
Why it's wrong here
zip() combines multiple iterables but does not provide indexes of a single list.
- ✗
map()
Why it's wrong here
map() applies a function to each element but does not provide indices.
- ✓
enumerate()
Why this is correct
enumerate() provides both index and value directly.
- ✗
range()
Why it's wrong here
range() only generates indices; you would need to combine it with len() and indexing.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 498-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
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.