How to extract digit from a number?

fl rxjwg98 at gmail.com
Mon Jul 21 16:42:26 EDT 2014


On Monday, July 21, 2014 4:26:25 PM UTC-4, Tim Chase wrote:
> On 2014-07-21 13:14, fl wrote:
> You don't specify *what* is wrong or what constitutes "does not
> work".  If you provide an example of what you *do* want, folks here
> can help you get closer to the code you need to do what you intend.
> 
> -tkc

The original source input is:
>>> a = 1234
>>> [int(d) for d in str(a)] 

He hopes the output is:
>>> [1, 2, 3, 4] 

In fact, I get the output is:

>>> a = 1234
>>> [int(d) for d in str(a)] 
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
TypeError: 'str' object is not callable

BTW, I just add input:
>>> import string

The error is still there. 
Why does it say :"TypeError: 'str' object is not callable"?



More information about the Python-list mailing list