I need to create list1 containing another a set of lists with 8 elements. these are then appended to a second list where the last element is changed. I am a little confused as currently when I try to change the last element, it changes the last element of both lists.
Any help on this would be really appreciated:
from random import random
list1 = []
list2 = []
for x in xrange(10):
a, b, c, d, e, f, g = [random() for i in xrange(7)]
list1.append([x, a, b, c, d, e, f, g])
for y in xrange(len(list1)):
list2.append(list1[y])
print "Index: ", y, "\tlist1: ", list1[y][7]
print "Index: ", y, "\tlist2: ", list2[y][7]
list2[y][7] = "Value for list2 only"
print "Index: ", y, "\tlist1: ", list1[y][7]
print "Index: ", y, "\tlist2: ", list2[y][7]