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()?

  1. A.

    A Python list containing exactly 3 strings.

  2. B.

    A Python tuple containing exactly 3 strings.

  3. C.

    A Python list containing at least 3 strings.

  4. 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:

  1. The part before the separator

  2. The separator itself

  3. The part after the separator

Hence, its return type is a tuple with exactly 3 elements.

Explore the full course: Rssb Senior Computer Instructor