Does Python have something like an empty string variable where you can do:
if myString == string.empty:
Regardless, what\'s the most elegan
Below is a simple method to identify an empty string:
a="" #Empty string
if(len(a)==0): #len() is used to find the length of the string or variable inside its' brackets.
print("Empty")
else:
print("Filled")
The above len() method is an inbuilt function that helps us to find the length of a certain string or variable. It can also be used in the case of lists.
LOGIC: If the length of the character or variable is 0 then absolutely it means that the string or variable is empty. BUT remember that this will work only in the case of strings and lists and not with integers. Below is the code to find length of integers.
a=int(input())
if(len(str(a))==0):
print(True)
In the above code str() is used to convert an int to a string format like from 123 to its string format "123". In the string format it will be valid.