Python

Python Menu

Python

Python String partition() - Definition, Syntax, Parameters, Examples

Definition

The partition() method searches for a specified string, and splits the string into a tuple containing three elements. The first element contains the part before the specified string; the second contains the specified string; the third contains the part after the string.

Syntax

string.partition(value)

Parameters

Parameter Description
value Required. The string to search for

Examples:

testStr = "Welcome to the Python tutorials." result = testStr.partition("the") print(result) # when specified value is not found result = testStr.partition("PHP") print(result)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods