I have this list:
["This is a set of words and it is not correct"]
I want to make it like this:
["This", "Is", "A"] ...
How do I do this
I have this list:
["This is a set of words and it is not correct"]
I want to make it like this:
["This", "Is", "A"] ...
How do I do this
"This is a set of words and it is not correct".title().split()
output:
['This', 'Is', 'A', 'Set', 'Of', 'Words', 'And', 'It', 'Is', 'Not', 'Correct']
You can do like this.
a = "This is a set of words and it is not correct"
[i.capitalize() for i in a.split()]
if input is list
as you mentioned in your question.
a = ["This is a set of words and it is not correct"]
[i.capitalize() for i in a[0].split()]
Output
['This', 'Is', 'A', 'Set', 'Of', 'Words', 'And', 'It', 'Is', 'Not', 'Correct']
Use the split()
method
>>> foo = ["This is a set of words and it is not correct"]
>>> foo[0].split()
['This', 'is', 'a', 'set', 'of', 'words', 'and', 'it', 'is', 'not', 'correct']