# 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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.devjugal.com/python/check-if-a-string-is-empty.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
