Question Detail

COS 102 Python strings Objective Question

Question

The 'No Space' Rule for string concatenation implies that:
Options
A Python automatically adds a single space between concatenated strings.
B The '+' operator will always remove any existing spaces in strings.
C You must explicitly add spaces as separate string literals if you want them.
Correct Answer
D Concatenation only works with strings that contain no spaces.
Correct Answer

Option C is the correct answer.

Detailed Explanation

The 'No Space' Rule (page 6) explicitly states: 'The + operator does not add spaces automatically. You must add them yourself!' The example name = "Alice" + " " + "Smith" demonstrates this by adding an empty space string in between.

Hint

Consider the example `"Alice" + " " + "Smith"` from the document.

Question Info