Python Language Loops The Pass Statement

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

pass is a null statement for when a statement is required by Python syntax (such as within the body of a for or while loop), but no action is required or desired by the programmer. This can be useful as a placeholder for code that is yet to be written.

for x in range(10):
    pass #we don't want to do anything, or are not ready to do anything here, so we'll pass

In this example, nothing will happen. The for loop will complete without error, but no commands or code will be actioned. pass allows us to run our code successfully without having all commands and action fully implemented.

Similarly, pass can be used in while loops, as well as in selections and function definitions etc.

while x == y:
    pass


Got any Python Language Question?