Periksa apakah string adalah python kosong
my_str = ""
if not my_str:
print("empty")
else:
print("not empty")
#output: empty
Doubtful Dingo
my_str = ""
if not my_str:
print("empty")
else:
print("not empty")
#output: empty
if variable:
# code goes here...
while True:
inp = input("TYPE IN HERE: ")
inp2 = inp.strip() # STRIP IT BABY
if len(inp2) < 1:
print("BLANK INPUT :(")
else:
print(inp) # PRINTING THE ORIGINAL (inp) VALUE
>>> A = ""
>>> A == ""
True
>>> A is ""
True
>>> not A
True