Which string method, out of the following, will always break the string into 3…

2023

Which string method, out of the following, will always break the string into 3 parts in Python?

  1. A.

    break

  2. B.

    partition

  3. C.

    mid

  4. D.

    split

Attempted by 1481 students.

Show answer & explanation

Correct answer: B

Key idea: The partition() method always returns three parts: the part before the separator, the separator itself, and the part after it. Example: 'hello-world'.partition('-')

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Rssb Senior Computer Instructor