Split a String
Info:
You can use the split()
method to seperate a string into a list item by specifying the separator.
Here's an example:
The split()
method splits the string into substrings if it finds instances of the specified separator:
a = "Cheers, Friends!"
print(a.split(","))
So the output of the above command will give this:
['Cheers', ' Friends!']
On the example above, "," was chosen as a separator.