python 문법 오류나는 이유
조회수 3498회
print("당신이 태어난 년도를 입력하세요.")
birth-year = int(input())
age = 2017 - birth-year + 1
여기서 2번째줄에서 birth-year가 can't assign to operator라는데 왜 그런지 모르겟어요ㅠㅠ
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
1 답변
-
변수명으로 가능한 경우는 아래와 같습니다.
- A variable name must start with a letter or the underscore character
- A variable name cannot start with a number
- A variable name can only contain alpha-numeric characters, unicode(for python 3.x) and underscores (A-z, 0-9, and _ )
- Variable names are case-sensitive (age, Age and AGE are three different variables)
underscore 만 가능하지 마이너스 기호는 변수명에 사용할 수 없습니다.
즉 질문상의 코드인 birth-year 는 birth 변수에서 year 변수를 빼는 코드가 됩니다.
댓글 입력