Teachnique
      CourseRoadmaps
      Login

      OverviewCommentsUser InputNumbersBooleansHistoryHello World ProgramEnvironment SetupSyntaxVariablesData TypesType CastingUnicode SystemLiteralsOperators

      Control FlowBreak StatementContinue StatementPass StatementNested LoopsDecision MakingIf StatementIf-else StatementNested IF StatementMatch-Case StatementLoopsFor LoopsFor-else LoopsWhile Loops

      FunctionsBuilt-in FunctionsDefault ArgumentsKeyword ArgumentsKeyword-Only ArgumentsPositional ArgumentsPositional-Only ArgumentsArbitrary ArgumentsVariable ScopeFunction AnnotationsModules

      StringSlicing StringsModify StringsString ConcatenationString FormattingEscape CharactersString MethodsString Exercises

      ListsList ExercisesAccess List ItemsChange List ItemsAdd List ItemsRemove List ItemsLoop ListsList ComprehensionSort ListsCopy ListsJoin ListsList Methods

      TuplesAccess Tuple ItemsUpdate TuplesUnpack Tuple ItemsLoop TuplesJoin TuplesTuple MethodsTuple Exercises

      SetsAccess Set ItemsAdd Set ItemsRemove Set ItemsLoop SetsJoin SetsCopy SetsSet OperatorsSet MethodsSet Exercises

      DictionariesDictionary ExercisesAccess Dictionary ItemsChange Dictionary ItemsAdd Dictionary ItemsRemove Dictionary ItemsDictionary View ObjectsLoop DictionariesCopy DictionariesNested DictionariesDictionary Methods

      ArraysAccess Array ItemsAdd Array ItemsRemove Array ItemsLoop ArraysCopy ArraysReverse ArraysSort ArraysJoin ArraysArray MethodsArray Exercises

      File HandlingWrite to FileRead FilesRenaming and Deleting FilesDirectoriesFile Methods

      OOP ConceptsDynamic BindingDynamic TypingAbstractionObject and ClassesEncapsulationInterfacesPackagesInner ClassesAnonymous Class and ObjectsSingleton ClassWrapper ClassesEnumsReflectionClass AttributesClass MethodsStatic MethodsConstructorsAccess ModifiersInheritancePolymorphismMethod OverridingMethod Overloading

      Feedback

      Submit request if you have any questions.

      Course
      Pass Statement

      Python Tutorial

      This Python tutorial has been written for the beginners to help them understand the basic to advanced concepts of Python Programming Language. After completing this tutorial, you will find yourself at a great level of expertise in Python, from where you can take yourself to the next levels to become a world class Software Engineer.

      Pass Statement

      Python pass Statement

      Python pass statement is used when a statement is required syntactically but you do not want any command or code to execute.
      Python pass statement is a null operation; nothing happens when it executes. Python pass statement is also useful in places where your code will eventually go, but has not been written yet, i.e., in stubs).

      Syntax

      pass

      Example

      The following code shows how you can use the pass statement in Python
      for letter in 'Python':
      if letter == 'h':
      pass
      print ('This is pass block')
      print ('Current Letter :', letter)
      print ("Good bye!")
      When the above code is executed, it produces the following output
      Current Letter : P
      Current Letter : y
      Current Letter : t
      This is pass block
      Current Letter : h
      Current Letter : o
      Current Letter : n
      Good bye!

      Dummpy Infinite Loop with Pass

      This is simple enough to create an infinite loop using pass statement. For instance, if you want to code an infinite loop that does nothing each time through, do it with a pass:
      while True: pass # Type Ctrl-C to stop
      Because the body of the loop is just an empty statement, Python gets stuck in this loop. As explained earlier pass is roughly to statements as None is to objects — an explicit nothing.

      Using Ellipses ... as pass Alternative

      Python 3.X allows ellipses coded as three consecutive dots ...to be used in place of pass statement. This ... can serve as an alternative to the pass statement.
      For example if we create a function which does not do anything especially for code to be filled in later, then we can make use of ...
      def func1():
      ... # Alternative to pass
      
      def func2(): ... # Works on same line too
      
      func1() # Does nothing if called
      func2() # Does nothing if called

      Practice with Online Editor

      Note: This Python online Editor is a Python interpreter written in Rust, RustPython may not fully support all Python standard libraries and third-party libraries yet.
      Remember to save code(Ctrl + S Or Command + S) before run it.