Add split_lines snippet

This commit is contained in:
Angelos Chalaris
2019-08-20 16:15:15 +03:00
parent 35d8fcf781
commit 88084d3d30

17
snippets/split_lines.md Normal file
View File

@ -0,0 +1,17 @@
---
title: split_lines
tags: string,beginner
---
Splits a multiline string into a list of lines.
Use `str.split()` and `'\n'` to match line breaks and create a list.
```py
def split_lines(str):
str.split('\n')
```
```py
split_lines('This\nis a\nmultiline\nstring.\n') # 'This\nis a\nmultiline\nstring.\n'
```