반응형
파이썬에서 들여쓰기는 항상 중요합니다
그래서 파이썬에서 들여쓰기의 레벨 수준이 맞지 않을 경우 IndentationError: unexpected indent 에러가 발생합니다.
들여쓰기 수준 불일치
문제 코드:
if True:
print("First line")
print("Second line")
오류 메시지:
IndentationError: unexpected indent
해결 방법: 들여쓰기는 일정한 간격(보통 공백 4칸)으로 일관되게 유지해야 합니다.
if True:
print("First line")
print("Second line")
위 처럼
if 문에서 True뒤의 print문은 같은 레벨의 수준이기 때문에 같은 들여쓰기 수준을 유지해줘야 합니다.
#indentationError #python #error #debug #파이썬 #에러
반응형
'파이썬 > 에러 디버깅' 카테고리의 다른 글
NameError: name 'name' is not defined (0) | 2024.08.10 |
---|---|
IndentationError: unindent does not match any outer indentation level (0) | 2024.08.04 |
IndentationError: expected an indented block (0) | 2024.08.04 |
SyntaxError: invalid syntax (0) | 2024.08.04 |
SyntaxError: unexpected EOF while parsing (0) | 2024.08.04 |