# If statements

If statements are the most basic way of adding conditions to code, and they're very effective. If, else if, and else statements allow code to be run when a condition is met, another condition is met, or none of the conditions are met, respectively.

If statements, else if statements, and else statements open a section. If the if statement is not passed, this section will be ignored and the code will continue on.

Syntaxes:

{% code overflow="wrap" lineNumbers="true" %}

```python
if %condition%:
  %code%
else if %other condition%:
  %other code%
else:
  %otherwise code%
```

{% endcode %}

Here's an example of an if, else if, and else being used:

{% code overflow="wrap" lineNumbers="true" %}

```python
if (type of {_item}) = diamond:
  broadcast "Shiny!"
else if (type of {_item}) = emerald:
  broadcast "Also shiny!"
else:
  broadcast "Not shiny"
```

{% endcode %}

* If `{_item}` is a diamond, the "Shiny!" message will be sent, and the other two messages will not.
* If `{_item}` is an emerald, the "Also shiny!" message will be sent, and the other two messages will not.
* If `{_item}` is neither a diamond nor an emerald, the "Not shiny!" message will be sent, and the first 2 messages will not.


---

# 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://x8ight.gitbook.io/syntask/limiters/conditionals/if-statements.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.
