Site icon i2tutorials

Partition() method in Python String Module

Partition() method in Python String Module


partition method in string module splits the argument in the string into 3 parts. The first part is before the partition, the second part is the partition itself and the third part is after the partition.


Syntax:

str.partition()


Example-1:

text = "I can watch Harry Potter series all day"
x = text.partition("Harry Potter")
print(x)


Output:

Exit mobile version