I have a word:
'shrewd'
How can I convert it into:
['s','h','r','e','w','d']
I have tried:
delim = ','
x = 'shrewd'.split(delim)
x
But not working ,any friend can help ?
I have a word:
'shrewd'
How can I convert it into:
['s','h','r','e','w','d']
I have tried:
delim = ','
x = 'shrewd'.split(delim)
x
But not working ,any friend can help ?
There aren't any commas in your string, so you won't be able to get your desired output using .split()
.
Since strings are iterable, you can use:
data = 'shrewd'
print(list(data))
This outputs:
['s', 'h', 'r', 'e', 'w', 'd']