###### tags: `leetcode` `python3` cited by = https://hackmd.io/2KBqq0S0TqKvtqUHUhyyTg?edit # Learn `bit_length()` ## Only named int can use it. ```python= Python 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 1.length() File "<stdin>", line 1 1.length() ^ SyntaxError: invalid syntax >>> a=1; a.bit_length() 1 >>> a='1'; a.bit_length() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'str' object has no attribute 'bit_length' >>> a=1.1; a.bit_length() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'float' object has no attribute 'bit_length' >>> a=[]; a.bit_length() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'bit_length' >>> a=(1); a.bit_length() 1 >>> a=(1,1); a.bit_length() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'tuple' object has no attribute 'bit_length' >>> a={1}; a.bit_length() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'set' object has no attribute 'bit_length' >>> >>> a=map(str,[1,2]); a.bit_length() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'map' object has no attribute 'bit_length' >>> a=list(map(str,[1,2])); a.bit_length() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'list' object has no attribute 'bit_length' ```