0

why name-123 is not consider as a variable name ?

why should we use _ instant of - ?

30th Jul 2017, 8:09 PM
Ravin Rau
Ravin Rau - avatar
2 Answers
+ 7
Minus sign is an operator and the interpreter treats it as subtraction symbol right away. So it understands you want to subtract one value from another, and gets confused if it's not true.
30th Jul 2017, 8:17 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 1
That name wont work because it has a character that's not a letter, underscore or number. That's one of the rules in Python, variable names mustn't start with a number and can contain only letters, numbers and underscores, otherwise, an error occurs.
30th Jul 2017, 8:14 PM
Vukaơin Zeljić
Vukaơin Zeljić - avatar