Why Python Grammar Errors

Asked 2 years ago, Updated 2 years ago, 118 views

print("Enter the year you were born.")
birth-year = int(input())
age = 2017 - birth-year + 1

In the second line, the birthday-year is called can't sign to operator, but I don't know whyㅠㅠ

python syntax-error

2022-09-22 11:45

1 Answers

If it is possible with a variable name, it is as follows.

Only underscore is possible; negative symbols cannot be used for variable names.

In other words, the code on the question, the birthday-year, becomes the code that subtracts the year variable from the birthday variable.


2022-09-22 11:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.