Python cheatsheet
Menghapus banyak space pada string
label = "hello "
label.strip()
Loop
lists = [1,2,3,4]
for list in lists:
print(list)
i = 0
while i < 4:
print(i)
i+=1
String
replace
"hello".replace("h", "")
Function
lamda
x = lambda a : a + 10
print(x(5))
# output: 15
Data
# list
x = [1,2,3,4]
# dictionary
x = {
"key": "data"
}
# tuples
x = (1,2,3,4)