How to extract digit from a number?

Tim Chase python.list at tim.thechases.com
Mon Jul 21 22:26:25 CEST 2014


On 2014-07-21 13:14, fl wrote:
> I see the following example on line, but it does not work. I do not
> know what is wrong. Could you correct it for me?
> 
> I'm not sure what [1, 1, 0, 0, 0, 0, ...] has to do with 128, but
> if you want the base 10 digits:
> 
> >>> a = 1234
> >>> [int(d) for d in str(a)]
> >>> [1, 2, 3, 4]

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





More information about the Python-list mailing list