break up a value in a list to a list of individual items

Chris Rebert clp at rebertia.com
Sun Nov 9 12:18:17 CET 2008


On Sun, Nov 9, 2008 at 2:38 AM, r3bol <leon.san.email at gmail.com> wrote:
> Hi, sorry to post this, but I've had a really hard time finding how to
> do it.
> Q.
> How can I break up a value in a list to a list of individual items
> (preferably without importing any modules)?
> Like...
> ['12345'] (string)
> to
> [1, 2, 3, 4, 5] [numbers]

nums = [int(char) for char in '12345']

Note also that:
list("1234") == ["1", "2", "3", "4"]

And do be sure to read one of the several fine Python tutorials.

Cheers,
Chris
-- 
Follow the path of the Iguana...
http://rebertia.com

>
> Thanks.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list