Python, convert an integer into an index?

Ian Kelly ian.g.kelly at
Wed Sep 23 00:13:45 CEST 2015

On Sep 22, 2015 3:46 PM, "Chris Roberts" <thecjguy1 at> wrote:
> (How do I make it into an index? )
> Preferably something fairly easy to understand as I am new at this.
> results = 134523      #(Integer)
> Desired:
> results = [1, 2, 3, 4, 5, 2, 3]   #(INDEX)
> Somehow I see ways to convert index to list to int, but not back again.

I'm not sure what you mean by "index" in this context, but do you just want
to convert the integer into a list of its digits? The simple way is to
convert it to a string, then convert each character back to an int, and put
the results into a list. More efficient way would be to strip the digits
off one at a time by dividing modulo 10.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list