I'm not sure if your list is an existing list, or if you're building
it as you go.  For an existing list, here's how to append to a nested
item that's a list -- first, not in a loop, and then in a loop:

>>> list = [[12,3,4], [5,2,6],[2,3,4]]
>>> list[1].append(99)
>>> list
[[12, 3, 4], [5, 2, 6, 99], [2, 3, 4]]

for i in range(len(list)):
        list[i].append('x')

        
>>> list
[[12, 3, 4, 'x'], [5, 2, 6, 99, 'x'], [2, 3, 4, 'x']]
_______
To build a list that doesn't exist:
l = []
>>> for i in range(5):
        l.append([i])       # this adds a nested list
        l[i] += ['foo', i]  # this adds to the nested list (use append
                            # to append 1 item)

        
>>> l
[[0, 'foo', 0], [1, 'foo', 1], [2, 'foo', 2], [3, 'foo', 3], [4, 'foo', 4]]


-- 
Patricia J. Hawkins
Hawkins Internet Applications, LLC





_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to