回答編集履歴
1
追記
test
CHANGED
@@ -67,3 +67,23 @@
|
|
67
67
|
実行例
|
68
68
|
|
69
69
|
![イメージ説明](bfe7b3d9704c8984139a26c8cede23bb.png)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
追記:
|
74
|
+
|
75
|
+
jun68ykt さんの回答を元に、一行にしてみました。
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
```python3
|
80
|
+
|
81
|
+
>>> lis = ["hoge","hogehoge","fuga","fugafuga","hoge","fuga", "hoge","fuga"]
|
82
|
+
|
83
|
+
>>> [x + "_" + str(lis[0:i].count(x) + 1) if lis[0:i].count(x) > 0 else x for i, x in enumerate(lis)]
|
84
|
+
|
85
|
+
['hoge', 'hogehoge', 'fuga', 'fugafuga', 'hoge_2', 'fuga_2', 'hoge_3', 'fuga_3']
|
86
|
+
|
87
|
+
>>>
|
88
|
+
|
89
|
+
```
|