PCAP Strings Practice Question
Which THREE of the following string methods can be used to split a string into a list of substrings? (Choose three.)
⚠ Common exam trap
The PCAP exam often tests the distinction between methods that return a list (`split`, `rsplit`, `splitlines`) versus those that return a tuple (`partition`, `rpartition`) or a single string (`join`), leading candidates to mistakenly select `partition` or `join`.
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
✓
splitlines()
The `splitlines()` method splits a string at line boundaries (like \n, \r\n, or \r) and returns a list of substrings, making it a valid method for splitting a string into a list. It is specifically designed for handling multi-line strings.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
splitlines()
Why this is correct
splitlines() splits a string at Unicode line boundaries such as \n, \r\n, \r, \v, \f, and other line separator characters, returning a list of lines without the line terminators unless keepends=True is passed. It does not accept a separator argument and does not split on spaces or tabs, making it ideal for line-oriented data like file contents or multi-line text.
- ✓
split()
Why this is correct
split() is the general-purpose string splitting method: it divides a string into a list of substrings using whitespace as the default delimiter, collapsing consecutive whitespace and stripping leading/trailing spaces. If a separator string is supplied, it splits exactly on that delimiter and preserves empty strings between consecutive separators, giving fine control over tokenization.
- ✗
join()
Why it's wrong here
join() is the inverse operation of split(): it takes an iterable of strings and concatenates them into a single string, inserting the calling separator between each element. It does not split or break a string into parts; rather, it merges multiple strings into one, so it is categorically wrong when the goal is to produce a list from a single string.
- ✓
rsplit()
Why this is correct
rsplit() works like split() but processes the string from the right end, which has a visible effect only when the maxsplit parameter is specified. For example, 'a,b,c'.rsplit(',', 1) returns ['a,b', 'c'], whereas split() with the same arguments would return ['a', 'b,c']; without maxsplit, both methods produce identical lists. This makes rsplit() the right choice when you need to split from the tail, such as extracting a file extension.
- ✗
partition()
Why it's wrong here
partition() returns a fixed 3-tuple (head, separator, tail) where the string is split only at the first occurrence of the separator argument, not at every occurrence. If the separator is not found, the tuple contains the original string followed by two empty strings. Because it always yields exactly three elements and does not return a list of arbitrary length, it cannot serve as a general splitting method.
Go deeper
Related to this question
About these practice questions
One of 421 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.