I have tried creating the following function:
def 3utr():.
do_something()
However, I get a SyntaxError. Replacing the “3” by “three” fixes the problem.
My questions are:
- Why is it a syntax error?
- Is there a way to have a function name start with a number in Python 3?
It is a syntax error because the language specification does not allow identifiers to start with a digit. So it’s not possible to have function names (which are identifiers) that start with digits in Python.
Python 2 Language Reference
Python 3 Language Reference