PCAP Strings Practice Question
What is the output of `print('-'.join(['a', 'b', 'c']))`?
⚠ Common exam trap
Python Institute often tests whether candidates understand that `join()` returns a single string, not a list or tuple, and that the separator is placed between elements, not appended at the ends.
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
✓
a-b-c
The `join()` method in Python concatenates the elements of an iterable (here, a list of strings) into a single string, using the string on which it is called as the separator. In this case, `'-'.join(['a', 'b', 'c'])` inserts a hyphen between each element, producing the string `'a-b-c'`. The `print()` function then outputs that string without quotes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
a-b-c
Why this is correct
The `str.join()` method returns a single string built by concatenating each element of the iterable with the given separator placed between them. Since the separator is '-' and the elements are 'a', 'b', and 'c', the correct printed output is the string `a-b-c`. The quotes are only part of the string literal in code, not part of the printed value, so the output has no brackets or extra characters.
- ✗
['a', '-', 'b', '-', 'c']
Why it's wrong here
The `str.join()` method never returns a list; it returns a single `str` object. If the result were a list, the printed representation would include square brackets and quotes, such as `['a', '-', 'b', '-', 'c']`, which would mean the hyphens are separate list elements. In reality, the hyphens are only delimiters inserted inside one string, so the output is `a-b-c` with no brackets and no per-element quotes.
- ✗
('a', '-', 'b', '-', 'c')
Why it's wrong here
A tuple result would appear with parentheses and commas, like `('a', '-', 'b', '-', 'c')`, and would again imply the separator is a separate element. However, `join()` is a method of the string type and its return type is always `str`, never a `tuple` or any other container. The actual printed result has hyphens only as glue between the characters, not as entries in a separate tuple, so the parentheses and commas are absent.
- ✗
a,b,c
Why it's wrong here
The output `a,b,c` would be produced by joining with a comma, e.g., `','.join(['a', 'b', 'c'])`, or by passing the three strings as separate arguments to `print` with a custom separator. But the delimiter in the question is a hyphen, not a comma, and `print` with multiple arguments defaults to a space separator, not a comma. Therefore the correct result is a single string `a-b-c`, not a comma-separated display.
Go deeper
Related to this question
About these practice questions
This PCAP question is part of Courseiva's 421-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 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.