回答編集履歴
2
もちょっと良い案
test
CHANGED
@@ -3,3 +3,17 @@
|
|
3
3
|
correct = lambda s: s.translate(str.maketrans("015", "OIS"))
|
4
4
|
|
5
5
|
```
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
# 追記:lambdaの代入は気持ち悪いのでそれを避けた案
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
```python
|
14
|
+
|
15
|
+
from operator import methodcaller
|
16
|
+
|
17
|
+
correct = methodcaller('translate', str.maketrans("015", "OIS"))
|
18
|
+
|
19
|
+
```
|
1
文字列メソッドを使用する
test
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
```python
|
2
2
|
|
3
|
-
correct = lambda s: s
|
3
|
+
correct = lambda s: s.translate(str.maketrans("015", "OIS"))
|
4
4
|
|
5
5
|
```
|