# How to use Python pass

Python pass is a placeholder which prevents the program from issuing an error message. The statement protects the syntax.

## What is Python pass?

Python pass acts primarily as a placeholder without any other basic functions. In some cases, it may be important to include a statement in the code to instruct the program to continue running. This prevents [problems in Python](https://www.ionos.co.uk/digitalguide/websites/web-development/troubleshooting-common-python-problems/). A typical example would be when a code has an empty space which has been created for a function, but it has **not developed yet**. An error message would pop up here if the body was left empty. Python pass prevents this. The placeholder can be replaced by the actual function later on and the code will remain correct.

## How is Python pass used?

Python pass uses the pass command and is placed within the code block. Python pass is used primarily in loops, where a certain function may not have been defined yet. The placeholder is often used after an `if´ statement. It will look like this:

```none
if some_condition:
    print("Condition encountered")
else:
    pass
```

Python pass can also be combined with other statements.

## How does Python pass work?

Python pass working in a loop is somewhat similar to the police directing traffic after an accident. The program begins the first pass, queries a defined condition, checks whether it is true or false, and proceeds accordingly. However, if the developer did not include a consequence, the program would issue an error sign here. Python pass would then steer the program past the `accident point´ and ensure that the **query continues to run without interruption**.

The right **examples** illustrate how Python pass is used and highlights statement’s advantages. A number series will be created with a [Python `for´ loop](https://www.ionos.co.uk/digitalguide/websites/web-development/python-for-loop/) in the first example. The program keeps counting up from 0. The termination condition states that the number should not become greater than or equal to 10. You would normally insert a restriction once the counter reaches 8 using a [Python `if else´ statement](https://www.ionos.co.uk/digitalguide/websites/web-development/python-if-else/). However, Python pass removes this restriction and tells the program to simply continue.


This is a markdown version of: [https://www.ionos.co.uk/digitalguide/websites/web-development/python-pass/](https://www.ionos.co.uk/digitalguide/websites/web-development/python-pass/) for AI/LLM consumption.