split()
say it: “SPLIT” /ˈsplɪt/
Breaks a string into a list of pieces.
What does split() do?
split() breaks a string into a list of pieces. By default it splits on spaces; you can pass a different separator.
line = "Ana,32,Denver"
parts = line.split(",")
print(parts) # ['Ana', '32', 'Denver']
Level: Apprentice · More Python terms at this level
Updated