回答編集履歴
2
修正
test
CHANGED
@@ -34,9 +34,13 @@
|
|
34
34
|
|
35
35
|
lines = [
|
36
36
|
|
37
|
-
' '.join(
|
37
|
+
' '.join(
|
38
38
|
|
39
|
+
filter(lambda v: v is not None, block)
|
40
|
+
|
41
|
+
)
|
42
|
+
|
39
|
-
for block in zip_longest(*[iter(data)]*3
|
43
|
+
for block in zip_longest(*[iter(data)]*3)
|
40
44
|
|
41
45
|
]
|
42
46
|
|
@@ -46,7 +50,7 @@
|
|
46
50
|
|
47
51
|
|
48
52
|
|
49
|
-
**実行結果** [Wandbox](https://wandbox.org/permlink/
|
53
|
+
**実行結果** [Wandbox](https://wandbox.org/permlink/cXvnQNigxDdcIAQe)
|
50
54
|
|
51
55
|
```plain
|
52
56
|
|
1
追記
test
CHANGED
@@ -7,3 +7,53 @@
|
|
7
7
|
lines2.append(threeline)
|
8
8
|
|
9
9
|
```
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
書いてみた
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
面白そうだったので。私ならこう書きます。
|
18
|
+
|
19
|
+
```Python
|
20
|
+
|
21
|
+
from itertools import zip_longest
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
with open('tekitou.txt') as fin:
|
28
|
+
|
29
|
+
data = fin.read().split()
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
lines = [
|
36
|
+
|
37
|
+
' '.join(block).rstrip()
|
38
|
+
|
39
|
+
for block in zip_longest(*[iter(data)]*3, fillvalue='')
|
40
|
+
|
41
|
+
]
|
42
|
+
|
43
|
+
print(*lines, sep='\n')
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
**実行結果** [Wandbox](https://wandbox.org/permlink/avP4I9zdPR3rP54L)
|
50
|
+
|
51
|
+
```plain
|
52
|
+
|
53
|
+
あ,い,う,え か,き,く,け こ,,
|
54
|
+
|
55
|
+
た,ち,,つ な,に,ぬ,ね は,ひ,ふ,へ
|
56
|
+
|
57
|
+
ま,み,む,
|
58
|
+
|
59
|
+
```
|