> For the complete documentation index, see [llms.txt](https://til.devjugal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.devjugal.com/python/check-if-a-string-is-empty.md).

# Check If a String is Empty

A string can be checked if it's empty or not by following ways -

## Simple Way

```python
my_var = ""
if my_var == "":
    print("Variable is empty!")
else:
    print("Variable is not empty!")
```

Here we just compare the variable to an empty string.

## Advanced Way

```python
my_var = ""
if my_var:
    print("Variable is not empty!") # True when a non-empty string is found
else:
    print("Variable is empty!") # True when an empty string is found
```

***Source:*** [***StackOverFlow***](https://stackoverflow.com/a/9926466)
