Do you want to know the details regarding “how to split a string by character in python”. If yes, you’re in the correct post.
how to split a string by character in python
def split(word): return [char for char in word] # Driver code word = 'geeks' print(split(word)) #Output ['g', 'e', 'e', 'k', 's']
string = 'James Smith Bond' x = string.split(' ') #Splits every ' ' (space) in the string to a list # x = ['James','Smith','Bond'] print('The name is',x[-1],',',x,x[-1])
I hope this article helps you to know about “how to split a string by character in python”. If you have any queries regarding this article please let us know via the comment section. Share this article with your friends & family via social networks.