Question Detail

COS 102 Advanced Text Processing Objective Question

Question

If you have the string `text = "a,b"` and you apply the method `text.split(",")`, what will be the output?
Options
A ["a,b"]
B ("a", "b")
C ["a", "b"]
Correct Answer
D "a" "b"
Correct Answer

Option C is the correct answer.

Detailed Explanation

The .split(separator) method breaks text into a list of chunks using the specified separator. For "a,b".split(","), the string is split at the comma, resulting in the list ["a", "b"].

Hint

The `split()` method always returns a list of substrings.

Question Info