PCAP Strings Practice Question
What is the result of 'abcdef'[::-2]?
⚠ Common exam trap
Candidates often mistakenly think that [::-2] starts from the beginning and skips every two characters forward, leading them to pick 'ace' (option B) instead of understanding that a negative step reverses the traversal order.
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
✓
'fdb'
The slicing syntax [::-2] means start from the end (default step negative), go to the beginning, and take every second character in reverse order. For 'abcdef', starting at 'f' (index -1), then skipping one to 'd' (index -3), then 'b' (index -5), resulting in 'fdb'. Option C is correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
'dfb'
Why it's wrong here
'dfb' is not the result of any single slice of 'abcdef' with a step of 2. If you slice forward starting at index 1 with step 2, you get 'bdf', not 'dfb'. The correct backward slice [::-2] returns 'fdb', so 'dfb' simply mixes up the order of the correct characters and is thus wrong.
- ✗
'ace'
Why it's wrong here
'ace' is exactly what you get from the forward slice 'abcdef'[::2], which selects indices 0, 2, and 4. However, the problem requires a step of 2 starting from the end of the string, which is indicated by a negative step. Using a positive step with default start of 0 gives 'ace' but is not the correct answer.
- ✓
'fdb'
Why this is correct
'fdb' is the correct result of the slice 'abcdef'[::-2]. The negative step tells Python to traverse the sequence backward from the last character, selecting 'f' (index 5), then 'd' (index 3), then 'b' (index 1). This is the only option that matches the requested backward, every-other-character behavior.
- ✗
'eca'
Why it's wrong here
'eca' is not produced by a single slice with step 2. It would result from first reversing the string to 'fedcba' and then taking every second character starting at index 1: 'fedcba'[1::2] gives 'eca'. The correct approach is a single negative-step slice on the original string, not a two-step reverse-then-slice operation.
Go deeper
Related to this question
About these practice questions
One of 169 original PCAP 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 →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCAP 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 PCAP exam.