Python does not output errors or output just because the indent is misaligned

I'm currently studying Python at a new company, but unlike other languages, Python can cause errors or not be processed correctly just by shifting the indentation.

In the sample.py below, the output result will be answer.py.

sample.py


for i in range(10):
    if i == 1:
        continue
    if i == 8:
        break
    print(i)

answer.py


0
2
3
4
5
6
7

However, in the following sample2.py, which is out of indentation, no error occurs, but print (i) is not output because the indentation is out of alignment.

sample2.py


for i in range(10):
    if i == 1:
        continue
    if i == 8:
        break
        print(i)

Recommended Posts

Python does not output errors or output just because the indent is misaligned
A story that pyenv is stuck because the python execution command PATH does not pass
Python> Python does not include the last offset
Python log is not output with docker-compose up
[Python] Boolean operator (or / and) does not return Boolean value
Python3 datetime is faster just by specifying the timezone
python> check NoneType or not> if a == None:> if a is None:
python (2) requires self because the method is an instance method
Test.py is not reflected on the web server in Python3.
[Verification] Just because there is deep learning, it does not mean that the recovery rate can easily exceed 100% in horse racing.
[Python] Which is executed first, the class variable or __init__?
[Python] Is the zero but non-empty object Truthy or Fallsy?
Python> default argument does not initialize mutable object (eg list) / because it is initialized at definition
Python round is not strictly round
Python list is not a list
Python version does not switch
[Python] Not just count collections.Counter
Build Python environment on Ubuntu (when pip is not the default)
[Introduction to Python] How to use the Boolean operator (and ・ or ・ not)
How to input a character string in Python and output it as it is or in the opposite direction.