回答編集履歴
1
追記
answer
CHANGED
@@ -1,4 +1,14 @@
|
|
1
1
|
ヒントだけ。
|
2
2
|
groupbyのkeyを指定すればできそうです。
|
3
3
|
|
4
|
-
[10.1. itertools — 効率的なループ実行のためのイテレータ生成関数 — Python 3.6.5 ドキュメント](https://docs.python.jp/3/library/itertools.html#itertools.groupby)
|
4
|
+
[10.1. itertools — 効率的なループ実行のためのイテレータ生成関数 — Python 3.6.5 ドキュメント](https://docs.python.jp/3/library/itertools.html#itertools.groupby)
|
5
|
+
|
6
|
+
### ついでに
|
7
|
+
この処理ですが、
|
8
|
+
```python
|
9
|
+
for x in range(N):
|
10
|
+
if data[x][0] == data[x+1][0]:
|
11
|
+
print("OK")
|
12
|
+
```
|
13
|
+
x+1するとリストのインデックスの上限をはみ出してしまうのは当然です。
|
14
|
+
安直な対処法ですが、range(N-1)にするととりあえず落ちなくはなります。
|