-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod_strip.py
More file actions
36 lines (27 loc) · 841 Bytes
/
Copy pathmethod_strip.py
File metadata and controls
36 lines (27 loc) · 841 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
35
36
# -- Method String --
# https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip
# Catatan:
# Semua method/metode/fungsi string mengembalikan nilai baru.
# Mereka tidak mengubah string asli.
# fungsi strip() menghapus semua karakter awal (spasi di awal) dan akhir
# (spasi di akhir) (karakter default/standarnya adalah spasi yang akan dihapus)
# Syntax
# string.strip(karakter)
# Nilai Parameter
# Parameter Deskripsi
# karakter Opsional. Satu set karakter untuk dihapus sebagai karakter utama/pengikut
x = " hello world "
print(x.strip())
# Output:
# hello world
y = "...hello world..."
print(y.strip('.'))
# Output:
# hello world
x = "https://www.google.com"
print(x.strip('htps:/'))
# Output:
# www.google.com
print("hello world".strip('abcdefgh'))
# Output:
# llo worl