Python treats 1.
as a beginning of a float number, but fails to parse the rest of the line. Change it to
(1).bit_length()
by enclosing the number literal with parenthesis, we make sure that python evaluates the expression within the parens, which is 1
and call the method on that number.
Python defines floating point literal like this
floatnumber ::= pointfloat | exponentfloat
pointfloat ::= [intpart] fraction | intpart "."
exponentfloat ::= (intpart | pointfloat) exponent
intpart ::= digit+
fraction ::= "." digit+
exponent ::= ("e" | "E") ["+" | "-"] digit+
As per that definition, the lexical analyzer thinks that 1.bit_length()
would be a float literal, since 1.
matches the [intpart] fraction
's beginning. But the rest of the line doesn't match. That is why it fails.