-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod_split.py
More file actions
34 lines (25 loc) · 998 Bytes
/
method_split.py
File metadata and controls
34 lines (25 loc) · 998 Bytes
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
# -- Method String --
# https://docs.python.org/3/library/stdtypes.html?highlight=split#str.split
# Catatan:
# Semua method/metode/fungsi string mengembalikan nilai baru.
# Mereka tidak mengubah string asli.
# fungsi split() membagi string menjadi tipe data list.
# Syntax
# string.split(separator, maxsplit)
# Nilai Parameter
# Parameter Deskripsi
# separator Opsional. Menentukan pemisah yang akan digunakan saat memisahkan string. Secara default/standarnya setiap spasi adalah pemisah
# maxsplit Opsional. Menentukan berapa banyak split yang harus dilakukan. Nilai default adalah -1, yang merupakan "semua kejadian"
x = "Hello World"
print(x.split())
# Output:
# ['Hello', 'World']
x = "alice#carl#eliot"
print(x.split('#'))
# Output:
# ['alice', 'carl', 'eliot']
x = "alice#carl#eliot"
print(x.split('#', 1))
# Output:
# ['alice', 'carl#eliot']
# jika ingin mempelajari lebih lanjut tentang Method-List kunjungi folder_name: "Method-List"