banner

© 2004-21 ict4u.net

Python List Create

How to create a list from a string or sentence.
Convert a list back to a string
# Make a list from a sentence
phrase = "A Fool and His Money Are Soon Parted"
phraseList = phrase.split()

print(phraseList)

# Make a list from a string
word = "Extraordinary"
wordList = list(word)

print(wordList)

# making a string from a list
phraseNew = " ".join(phraseList)
print(phraseNew)

wordNew = "".join(wordList)
print(wordNew)