此代码:
total = 12
for i in range(1, total+1, 3):
x = [x for x in range(i, i+3)]
print(x)
print(x.insert(0, 0))
在Python 3.7上打印出以下内容:
[1, 2, 3]
None
[4, 5, 6]
None
[7, 8, 9]
None
[10, 11, 12]
None
我希望它打印出来:
[1, 2, 3]
[0, 1, 2, 3]
[4, 5, 6]
[0, 4, 5, 6]
[7, 8, 9]
[0, 7, 8, 9]
[10, 11, 12]
[0, 10, 11, 12]
我在做什么错了?