Pass Statement in Python

The pass statement in Python is a placeholder. It does nothing when executed, but it's used when a statement is syntactically required.

It is useful when we write code structures like loops, functions, or conditions but don't want to run any code inside them *yet*.

Syntax:

if condition:
    pass
# or inside loops or functions
for item in list:
    pass

Note: Without pass, Python will give an error if a block is left empty.

Example 1: Using pass in if-statement

x = 5
if x > 0:
    pass
print("Check completed.")

Output:

Check completed.

Explanation:

  • The if condition x > 0 is true.
  • Instead of running any code, we use pass as a placeholder.
  • The program continues and prints "Check completed."

Example 2: Using pass inside a loop (reserved space)

for i in range(3):
    pass
print("Loop ended")

Output:

Loop ended

Explanation:

  • This loop runs 3 times, but pass means "do nothing" for each iteration.
  • No output appears from the loop, but the program still runs correctly.
  • It then prints "Loop ended".

Summary:

  • pass means “do nothing”.
  • Used as a placeholder where a block of code is required but not ready yet.
  • Prevents errors in empty loops, functions, or conditions.

Welcome to ShikshaSanchar!

ShikshaSanchar is a simple and helpful learning platform made for students who feel stressed by exams, assignments, or confusing topics. Here, you can study with clarity and confidence.

Here, learning is made simple. Notes are written in easy English, filled with clear theory, code examples, outputs, and real-life explanations — designed especially for students like you who want to understand, not just memorize.

Whether you’re from school, college, or someone learning out of curiosity — this site is for you. We’re here to help you in your exams, daily studies, and even to build a strong base for your future.

Each note on this platform is carefully prepared to suit all levels — beginner to advanced. You’ll find topics explained step by step, just like a good teacher would do in class. And the best part? You can study at your pace, anytime, anywhere.

Happy Learning! – Team ShikshaSanchar