Answers for "python check string empty"

18

check if string is empty python

my_str = ""
if not my_str:
  print("empty")
else:
  print("not empty")
#output: empty
Posted by: Guest on May-09-2020
3

how to check empty string in python

my_empty_string = ''  # given the empty string a variable

def check_empty():
    if not my_empty_string: 
        print("Empty")
    else:
        print("Not Empty")


check_empty()



# by George Kwabena
Posted by: Guest on September-01-2020
0

check if value is empty python

a_variable = {}

is_a_empty = bool(a_variable)

print(is_a_empty)
# >>> False


b_variable = [1, 2, 3]

is_b_empty = bool(b_variable)

print(is_b_empty)
# >>> True
Posted by: Guest on June-09-2021

Python Answers by Framework

Browse Popular Code Answers by Language