回答編集履歴

2

追記

2018/08/28 14:48

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -73,3 +73,27 @@
73
73
 
74
74
 
75
75
  [Wandbox](https://wandbox.org/permlink/LBus20vcVK0dwmBq)
76
+
77
+
78
+
79
+ どうしても一周で完成させたい場合は、こんな感じです。
80
+
81
+ ```Python
82
+
83
+ a = []
84
+
85
+ b = []
86
+
87
+
88
+
89
+ for *elems, last in data:
90
+
91
+ a.append(elems)
92
+
93
+ b.append(last)
94
+
95
+ ```
96
+
97
+
98
+
99
+ [Wandbox](https://wandbox.org/permlink/WIbLudk5TTYufIJp)

1

追記

2018/08/28 14:48

投稿

LouiS0616
LouiS0616

スコア35658

test CHANGED
@@ -53,3 +53,23 @@
53
53
  [['aaa', 'bbb'], ['test', 'item'], ['test', 'item']]
54
54
 
55
55
  ```
56
+
57
+
58
+
59
+ 書いてみた
60
+
61
+ ---
62
+
63
+ 要素を二回参照する無駄はありますが、この方が分かりやすいように思います。
64
+
65
+ ```Python
66
+
67
+ a = [row[:-1] for row in data]
68
+
69
+ b = [row[-1] for row in data]
70
+
71
+ ```
72
+
73
+
74
+
75
+ [Wandbox](https://wandbox.org/permlink/LBus20vcVK0dwmBq)