list1 = [0,1,2,3,4,5,6,7,8,9]
list2 = []
a = 0
b = 2
for i in range(5):
c = list1[a:b]
list2.append(c)
a += 2
b += 2
print(list2)
### OUTPUT
# [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]
###
1次元のリストを2次元のリストに変換
[1,2,3,4,5,6,7,8,9]
⇨[[1,2,3][4,5,6][7,8,9]]
>>>jigen1=[1,2,3,4,5,6,7,8,9]
>>>jigen2=[]
>>>s1=1
>>>s2=3
>>>for i in range(10)
>>> a=jigen1[s1:s2]
>>> jigen2.append(a)
>>> s1+=3
>>> s2+=3
>>>print jigen2
[[1,2,3][4,5,6][7.8.9]]
0 件のコメント:
コメントを投稿