How to Convert a String into List in Python
A String can be converted into list using the
The split method is used to split the strings and store them in the list. It returns a list of the words in the string, with the ‘delimiter’ provided as the delimiter string. If the delimiter is not specified or is None, consecutive whitespace is regarded as a single separator, and the result will contain no empty strings at the start or end of the string has leading or trailing whitespace.
string_1 = "Python Point" print(string_1.split(" ")) string_2 = "Python-Point" print(string_2.split("-")) string_3 = "Python Point is great" print(string_3.split())
['Python', 'Point'] ['Python', 'Point'] ['Python', 'Point', 'is', 'great']
Please login to comment
View all comments