I have a list with the following structure:
l = [[[],0]] * 5
each node in the list contains another list:
- first element in the inner list contains another list
- second element in the inner list contains wight
I'm trying to add value to the inner list:
index = 0
l[index][0].append('s')
but it add the values 's'
to all list (l
) values:
l = [[['s'],0], [['s'],0], [['s'],0], [['s'],0], [['s'],0]]
- why the value 's' duplicates to all the list element ?
- how can I add the value 's' only to the first inner list
(i.e
l = [[['s'],0], [[],0], [[],0], [[],0], [[],0]]
)
Python 3.6.8