C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Python PassIn Python, the pass keyword is used to execute nothing; it means, when we don't want to execute code, the pass can be used to execute empty. It is the same as the name refers to. It just makes the control to pass by without executing any code. If we want to bypass any code pass statement can be used. It is beneficial when a statement is required syntactically, but we want we don't want to execute or execute it later. The difference between the comments and pass is that, comments are entirely ignored by the Python interpreter, where the pass statement is not ignored. Suppose we have a loop, and we do not want to execute right this moment, but we will execute in the future. Here we can use the pass. Consider the following example. Example - Pass statement # pass is just a placeholder for # we will adde functionality later. values = {'P', 'y', 't', 'h','o','n'} for val in values: pass Example - 2: for i in [1,2,3,4,5]: if(i==4): pass print("This is pass block",i) print(i) Output: 1 2 3 This is pass block 4 4 5 We can create empty class or function using the pass statement. # Empty Function def function_name(args): pass #Empty Class class Python: pass
Next TopicPython Strings
|