xxxxxxxxxx
my_str = ""
if not my_str:
print("empty")
else:
print("not empty")
#output: empty
xxxxxxxxxx
# Method 1: using len() function
my_string = "Hello, World!"
if len(my_string) == 0:
print("String is empty")
else:
print("String is not empty")
# Method 2: using direct comparison
if my_string == "":
print("String is empty")
else:
print("String is not empty")
xxxxxxxxxx
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