回答編集履歴
1
追記
test
CHANGED
@@ -11,3 +11,15 @@
|
|
11
11
|
>>> [*more_itertools.repeat_each(range(1, 6), n=3)]
|
12
12
|
[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]
|
13
13
|
```
|
14
|
+
|
15
|
+
さらに踏み込んで
|
16
|
+
---
|
17
|
+
必要なリスト長が前以て分からないときは次のように処理します。
|
18
|
+
```Python
|
19
|
+
import itertools
|
20
|
+
import more_itertools
|
21
|
+
|
22
|
+
it = more_itertools.repeat_each(itertools.count(start=1), n=3)
|
23
|
+
```
|
24
|
+
|
25
|
+
itはイテレータです。先頭から順に 1,1,1,2,2,2,3,3,3,... と値を取り出せます。
|