The split and join String Methods in Python


Split a string into a list and join a list into a string.

Source Code

# Split a string
sentence = "hello world"
words = sentence.split()
print(words)

# Join a list into a string
new_sentence = " ".join(words)
print(new_sentence)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments