Question Detail

COS 102 Python strings Objective Question

Question

When concatenating two strings, str1 and str2, using the + operator, what is true regarding spaces?
Options
A A space is automatically added between <code>str1</code> and <code>str2</code>.
B Spaces are only added if <code>str1</code> ends with a space.
C You must explicitly add a space string between <code>str1</code> and <code>str2</code> if desired.
Correct Answer
D Spaces are never allowed in concatenated strings.
Correct Answer

Option C is the correct answer.

Detailed Explanation

Page 6, under 'The "No Space" Rule', explicitly states: 'The + operator does not add spaces automatically. You must add them yourself!'

Hint

Remember the 'No Space' rule and how it affects string output.

Question Info