String: split

.split(), .splitlines(), .rsplit()

.split()


.splitlines()


.rsplit()

.split(), .splitlines(), .rsplit() Syntax

list_variable = string_variable.split(sep)


sep is an optional parameter, if a character is given, the string_variable will be split on that character

.split(), .splitlines(), .rsplit() Examples

.split() Example:

data before :

This is a file with many words

and many lines


data = data.split()


data after 

['This', 'is', 'a', 'file', 'with', 'many', 'words', 'and', 'many', 'lines']

Notice: the data started as a string and was converted into a list