-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod_splitlines.py
More file actions
39 lines (29 loc) · 1.16 KB
/
method_splitlines.py
File metadata and controls
39 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -- Method String --
# https://docs.python.org/3/library/stdtypes.html?highlight=splitlines#str.splitlines
# Catatan:
# Semua method/metode/fungsi string mengembalikan nilai baru.
# Mereka tidak mengubah string asli.
# fungsi splitlines() membagi string menjadi tipe data list.
# Pemisahan dilakukan pada jeda baris.
# Syntax
# string.splitlines(jedabaris)
# Nilai Parameter
# Parameter Deskripsi
# jedabaris Opsional. Menentukan apakah jeda baris harus disertakan (True), atau tidak (False). Nilai default adalah False
x = "hello \nworld"
print(x.splitlines())
# Output:
# ['hello ', 'world']
y = "hello \nworld"
print(y.splitlines(True))
# Output:
# ['hello \n', 'world']
x = """Python adalah bahasa pemrograman tujuan umum yang ditafsirkan,
tingkat tinggi. Dibuat oleh Guido van Rossum dan pertama kali dirilis pada tahun 1991,
filosofi desain Python menekankan keterbacaan kode dengan penggunaan spasi putih yang signifikan."""
print(x.splitlines())
x = "hello alice carl eliot"
print(x.splitlines())
# Output:
# ['hello alice carl eliot']
# jika ingin mempelajari lebih lanjut tentang Method-List kunjungi folder_name: "Method-List"