---
title: "What is the difference between break, continue, and pass?"  
description: "What is the difference between break, continue, and pass?"  
author: "ICSM Computer"  
published: 2025-03-27  
updated: 2025-03-27  
canonical: https://www.mindstick.com/interview/34015/what-is-the-difference-between-break-continue-and-pass  
category: "python"  
tags: ["python-3.4", "python"]  
reading_time: 3 minutes  

---

# What is the difference between break, continue, and pass?

In Python, `break`, `continue`, and `pass` are control flow statements used inside loops or conditionals. Here's how they differ:

### 1. `break`

- **Purpose**: Terminates the loop immediately.
- **Where Used**: Inside loops (`for` or `while`).
- **Effect**: The loop stops running when `break` is encountered.

```python
for i in range(5):
    if i == 3:
        break  # Exits the loop when i is 3
    print(i)
```

```plaintext
0
1
2
```

### 2. `continue`

- **Purpose**: Skips the current iteration and moves to the next.
- **Where Used**: Inside loops (`for` or `while`).
- **Effect**: The loop does not terminate but skips the remaining code for the current iteration.

```python
for i in range(5):
    if i == 3:
        continue  # Skips iteration when i is 3
    print(i)
```

```plaintext
0
1
2
4
```

### 3. `pass`

- **Purpose**: Acts as a placeholder for code that will be implemented later.
- **Where Used**: Anywhere (functions, loops, conditionals, etc.).
- **Effect**: Does nothing and moves to the next statement.

```python
for i in range(5):
    if i == 3:
        pass  # Does nothing, just a placeholder
    print(i)
```

```plaintext
0
1
2
3
4
```

### Summary:

| Statement | Purpose | Effect |
| --- | --- | --- |
| `break` | Exits the loop completely | Terminates the loop |
| `continue` | Skips the current iteration | Moves to the next iteration |
| `pass` | Placeholder for future code | Does nothing |

## Answers

### Answer by ICSM Computer

In Python, `break`, `continue`, and `pass` are control flow statements used inside loops or conditionals. Here's how they differ:

### 1. `break`

- **Purpose**: Terminates the loop immediately.
- **Where Used**: Inside loops (`for` or `while`).
- **Effect**: The loop stops running when `break` is encountered.

```python
for i in range(5):
    if i == 3:
        break  # Exits the loop when i is 3
    print(i)
```

```plaintext
0
1
2
```

### 2. `continue`

- **Purpose**: Skips the current iteration and moves to the next.
- **Where Used**: Inside loops (`for` or `while`).
- **Effect**: The loop does not terminate but skips the remaining code for the current iteration.

```python
for i in range(5):
    if i == 3:
        continue  # Skips iteration when i is 3
    print(i)
```

```plaintext
0
1
2
4
```

### 3. `pass`

- **Purpose**: Acts as a placeholder for code that will be implemented later.
- **Where Used**: Anywhere (functions, loops, conditionals, etc.).
- **Effect**: Does nothing and moves to the next statement.

```python
for i in range(5):
    if i == 3:
        pass  # Does nothing, just a placeholder
    print(i)
```

```plaintext
0
1
2
3
4
```

### Summary:

| Statement | Purpose | Effect |
| --- | --- | --- |
| `break` | Exits the loop completely | Terminates the loop |
| `continue` | Skips the current iteration | Moves to the next iteration |
| `pass` | Placeholder for future code | Does nothing |


---

Original Source: https://www.mindstick.com/interview/34015/what-is-the-difference-between-break-continue-and-pass

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
