Can an indentation error occur in a multi-line string or comment in Python?

Responsive Ad Header

Question

Grade: Education Subject: Support
Can an indentation error occur in a multi-line string or comment in Python?
Asked by:
75 Viewed 75 Answers

Answer (75)

Best Answer
(399)
Generally, indentation errors do not occur within multi-line strings (using triple quotes) or multi-line comments because Python treats the content within them as literal data and does not parse their internal whitespace for code block structure. However, if a line *outside* of a string or comment is incorrectly indented relative to the surrounding code, an indentation error will still be raised.