593 B
593 B
title, tags, expertise, cover, firstSeen, lastUpdated
| title | tags | expertise | cover | firstSeen | lastUpdated |
|---|---|---|---|---|---|
| Split into lines | string | beginner | blog_images/succulent-4.jpg | 2019-08-20T16:15:15+03:00 | 2020-11-02T19:28:35+02:00 |
Splits a multiline string into a list of lines.
- Use
str.split()and'\n'to match line breaks and create a list. str.splitlines()provides similar functionality to this snippet.
def split_lines(s):
return s.split('\n')
split_lines('This\nis a\nmultiline\nstring.\n')
# ['This', 'is a', 'multiline', 'string.' , '']