반응형
파이썬에서 잘못된 예약어를 사용시에 SyntaxError: invalid syntax 가 발생합니다.
잘못된 예약어 사용
문제 코드:
if True
print("This is True")
오류 메시지:
SyntaxError: invalid syntax
해결 방법: if 문이나 다른 조건문에서는 조건을 작성한 후에 콜론(:)을 추가해야 합니다.
if True:
print("This is True")
위와 같이 항상 조건문에서는 콜론이 있는지 확인을 하여야 하고 문법이 제대로 되었는지를 확인하여야 합니다.
반응형
'파이썬 > 에러 디버깅' 카테고리의 다른 글
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: unexpected EOF while parsing (0) | 2024.08.04 |
SyntaxError: expected an indented block (0) | 2024.08.04 |