Ошибка до индекса a[1]
.
пример:
x=[21,23,25,27]
y=[5,6,7,8]
z=x+y
print (z)
z[0]=45
print (z)
# a = list of lists, where x+y is the first and only list [[x+y],...]
a=[x+y]
print(a)
# print [x+y]
print (a[0])
# a[1][2] here 1 was out of bounds
# a[0][2] the third member of list [0], i.e. [x+y]
print (a[0][2])
# list of lists, with two memmbers [x, y]
a = [z,y]
print(a)
# first member of x
print(a[0][0])
# print first member of y
print(a[1][0])
Выход:
# print (z)
[21, 23, 25, 27, 5, 6, 7, 8]
# print(z)
[45, 23, 25, 27, 5, 6, 7, 8]
# print(a)
[[21, 23, 25, 27, 5, 6, 7, 8]]
# print(a[0])
[21, 23, 25, 27, 5, 6, 7, 8]
# print(a[0][2])
25
# print([z,y])
[[45, 23, 25, 27, 5, 6, 7, 8], [5, 6, 7, 8]]
# print a[0][0]
45
# print a[1][0]
5