Explain split() and join() method in Python?

Last updated 3 weeks, 5 days ago | 19 views 75     5

Tags:- Python

Python | split() and join()

You can use split() method to split a string based on a delimiter to a list of strings. and join() method is used to join a list of strings based on a delimiter to give a single string.


Split a string into a list

txt = "Split function breaks down a larger string"


Join all items in a tuple into a string

myTuple = ("John", "Peter", "Vicky")

x = "-".join(myTuple)