Yes, they do completely different things. pass
simply does nothing, while continue
goes on with the next loop iteration. In your example, the difference would become apparent if you added another statement after the if
: After executing pass
, this further statement would be executed. After continue
, it wouldn’t.
>>> a = [0, 1, 2] >>> for element in a: ... if not element: ... pass ... print(element) ... 0 1 2 >>> for element in a: ... if not element: ... continue ... print(element) ... 1 2
Related Posts:
- What does “while True” mean in Python?
- What is the difference between {} and [] in python?
- syntaxerror: “unexpected character after line continuation character in python” math
- How do you express binary literals in Python?
- Can someone explain __all__ in Python?
- How to exit a loop in Python?
- How can I do a line break (line continuation) in Python?
- What does the /= operator mean in Python?
- What do >> and << mean in Python?
- What does `<>` mean in Python?
- What does the “at” (@) symbol do in Python?
- What is :: (double colon) in Python when subscripting sequences?
- What’s the u prefix in a Python string?
- Python def function: How do you specify the end of the function?
- No Multiline Lambda in Python: Why not?
- What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
- Python integer incrementing with ++ [duplicate]
- What is the result of % in Python?
- What’s the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?
- IndentationError: unexpected indent error
- Putting a simple if-then-else statement on one line [duplicate]
- How can I do a line break (line continuation)?
- How do you comment out code in PowerShell?
- How do I break a string in YAML over multiple lines?
- What does ‘&’ do in a C++ declaration?
- syntaxerror: “unexpected character after line continuation character in python” math
- syntaxerror: “unexpected character after line continuation character in python” math
- `from … import` vs `import .` [duplicate]
- Tab space in Markdown
- syntax error when using command line in python
- In JavaScript is != same as !==
- What does ** (double star/asterisk) and * (star/asterisk) do for parameters?
- syntax error when using command line in python
- What Does This Mean in PHP -> or =>
- syntaxError: ‘continue’ not properly in loop
- syntaxError: ‘continue’ not properly in loop
- Comments in Markdown
- How do I pass multiple parameters into a function in PowerShell?
- syntaxError: ‘continue’ not properly in loop
- Comments in Markdown
- What is the difference between syntax and semantics in programming languages?
- Python: SyntaxError: keyword can’t be an expression
- What do << or >>> in java mean?
- What is the Java ?: operator called and what does it do?
- How do I convert a float number to a whole number in JavaScript?
- hat does “static” mean in C?
- How to normalize a 2-dimensional numpy array in python less verbose?
- Ternary operator (?:) in Bash
- SyntaxError invalid token
- What is the difference between ‘/’ and ‘//’ when used for division?
- Is there a difference between x++ and ++x in java?
- Printing variables in Python 3.4
- What does the “@” symbol do in PowerShell?
- Static Semantics meaning?
- What does the `and` keyword mean in OCaml?
- text highlight in markdown
- Error “‘type’ object has no attribute ‘__getitem__'” when iterating over list[“a”,”b”,”c”]
- Inline for loop
- What does ‘wb’ mean in this code, using Python?
- What does @@variable mean in Ruby?
- Python def marked as invalid syntax
- How do you format an unsigned long long int using printf?
- What are those pipe symbols for in Ruby?
- bash: syntax error near unexpected token `(‘ – Python
- Prolog “or” operator, query
- Remove all whitespace in a string
- What is a “method” in Python?
- How to generate all permutations of a list?
- Is there a Python equivalent to Ruby’s string interpolation?
- Python Progress Bar
- Most efficient way to find mode in numpy array
- Python error “ImportError: No module named”
- How to groupby based on two columns in pandas?
- proper name for python * operator?
- How to do superscripts and subscripts in Jupyter Notebook?
- How do I unload (reload) a Python module?
- “OverflowError: Python int too large to convert to C long” on windows but not mac
- Can’t compare naive and aware datetime.now() <= challenge.datetime_end
- List of zeros in python
- How to remove an element from a list by index
- How to add title to subplots in Matplotlib
- ‘pip3’ is not recognized as an internal or external command, operable program or batch file
- Apply function to each element of a list
- How to display text in pygame?
- Python Nested Loops To Print Rectangle With Asterisks
- Normalize columns of pandas data frame
- Python Error: “ValueError: need more than 1 value to unpack”
- Python: can’t assign to literal
- “Initializing” variables in python?
- How to perform bilinear interpolation in Python
- Python socket.error: [Errno 111] Connection refused
- Windows- Pyinstaller Error “failed to execute script ” When App Clicked
- Python CSV error: line contains NULL byte
- python NameError: name ‘file’ is not defined
- python BeautifulSoup parsing table
- Python Add to dictionary loop
- how to exit a python script in an if statement
- TypeError: ‘range’ object does not support item assignment
- Convert string to variable name in python
- Syntax highlighting in vim for python