split a list of strings python code example
Example 1: split string python
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[0],x[-1])
Example 2: python split list
string = 'this is a python string'
wordList = string.split(' ')
Example 3: python split list
string = "this is a string" # Creates the string
splited_string = string.split(" ") # Splits the string by spaces
print(splited_string) # Prints the list to the console
# Output: ['this', 'is', 'a', 'string']