What is the return type and structure of the Python string function partition()?
2026
What is the return type and structure of the Python string function partition()?
- A.
A Python list containing exactly 3 strings.
- B.
A Python tuple containing exactly 3 strings.
- C.
A Python list containing at least 3 strings.
- D.
A Python tuple containing at least 3 strings.
Attempted by 512 students.
Show answer & explanation
Correct answer: B
The correct answer is Option B.
The partition() function in Python returns a tuple containing exactly three strings. These three parts are:
The part before the separator
The separator itself
The part after the separator
Hence, its return type is a tuple with exactly 3 elements.