반응형
파이썬에서
SyntaxError: expected an indented block
와 같은 에러가 날 경우 들여쓰기가 잘못 되었을때 발생하기 마련 입니다.
문제 코드: 아래와 같이 def 다음에는 들여쓰기가 와야 합니다
def example():
print("Hello, World!")
오류 메시지:
SyntaxError: expected an indented block
해결 방법: 함수나 조건문 등의 블록 안에서는 들여쓰기를 사용해야 합니다.
def example():
print("Hello, World!")
위와 같이 들여쓰기를 완료 하여주면 해당 함수 실행시 문제 없이 코드가 진행되는 것을 보실수 있습니다.
#파이썬 #error #syntaxError #expected #debug
반응형
'파이썬 > 에러 디버깅' 카테고리의 다른 글
IndentationError: unindent does not match any outer indentation level (0) | 2024.08.04 |
---|---|
IndentationError: unexpected indent (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 |