a = [1, 2, 3, 4, 5, 6, 7] step = 3 for i in range(0, len(a), step): print(a[i:i+step])
打印結果:ide
[1, 2, 3] [4, 5, 6] [7]