split a string by empty space in python
Code snippet on how to split a string by empty space in python
myString = "Hello World"
myList = myString.split(" ")
This code takes a string called myString and splits it into a list called myList by looking for empty spaces. The split() method looks for instances of the character, in this case an empty space, and splits the string wherever it occurs. “Hello World” is a string that has two words separated by an empty space, so when split() is called, it creates a list with two items, [“Hello”, “World”]. The original string is still stored in myString, while the list is stored in myList.