파이썬/에러 디버깅
IndentationError: unexpected indent
kimble2
2024. 8. 4. 16:01
반응형
파이썬에서 들여쓰기는 항상 중요합니다
그래서 파이썬에서 들여쓰기의 레벨 수준이 맞지 않을 경우 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 #파이썬 #에러
반응형