How to Use the Pass Statement in Python


Pass is an empty statement to maintain the integrity of the program structure. In this example, we will learn how to use the pass statement in Python.

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

for letter in 'Boston':
   if letter == 'o':
      pass
      print ('Passed')
   print ('Current alphabet :', letter)

Output:

Current alphabet : B
Passed
Current alphabet : o
Current alphabet : s
Current alphabet : t
Passed
Current alphabet : o
Current alphabet : n
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement