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)
Split a string into a list and join a list into a string.
# Split a string
sentence = "hello world"
words = sentence.split()
print(words)
# Join a list into a string
new_sentence = " ".join(words)
print(new_sentence)