What does dash sign(-) mean in python 3

1562 views python
3

Hello everyone and thank you for reading my question. I want to know why I can't use - sign in my variable, class.etc name

my-var = 10

print(my-var)

and this is what I got:

    my-var = 10
    ^
SyntaxError: can't assign to operator

answered question
khelwood

- is the subtraction operator. my-var means "my minus var"

Add a Comment

1 Answer

6
Chase 0 Comments

  • is subtract. It is not a valid character that can be used in var names. Read the Python Style Guide to see how to properly name variables and classes.

posted this

Please login first before posting an answer.