-
Notifications
You must be signed in to change notification settings - Fork 329
/
Copy pathMain.py
36 lines (29 loc) · 856 Bytes
/
Main.py
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
# operator dictionary
data_dict = {
"cup":"ucup surucup",
"tong":"otong surotong",
"dung":"dudung surudung"
}
# panjang dictionary
LENDICT = len(data_dict)
print(f"panjang dictionary: {LENDICT}")
# mengecek key exist atau tidak
KEY = "cup"
CHECKKEY = KEY in data_dict
print(f"apakah {KEY} ada di data_dict: {CHECKKEY}")
# mengakses value (read) dengan get
print(data_dict["cup"])
print(data_dict.get("cup"))
print(data_dict.get("kis","key tidak ditemukan")) # cek key dengan message tidak ditemukan
# mengupdate data
data_dict["cup"] = "ucup si ganteng"
print(data_dict)
data_dict["sep"] = "asep si kasyep"
print(data_dict)
data_dict.update({"cup":"ucup surucup"})
print(data_dict)
data_dict.update({"faqih":"faqihza si kweren"}) # kalau gak ada diadd ajah
print(data_dict)
# mendelete data pada dictionary
del data_dict["faqih"]
print(data_dict)