r3bol 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]

You did not specify what you want to happen if the original list has more than one item. If you want to keep the other items....

>>> lst = [1, '234', 5]
>>> lst[1:2] = [int(i) for i in lst[1]] # insert slice
>>> lst
[1, 2, 3, 4, 5]

>>> lst = [1, '234', 5]
>>> lst[1] = [int(i) for i in lst[1]] # insert item
>>> lst
[1, [2, 3, 4], 5]

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

Reply via email to