回答編集履歴

2

もちょっと良い案

2019/06/19 00:30

投稿

YouheiSakurai
YouheiSakurai

スコア6142

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

文字列メソッドを使用する

2019/06/19 00:30

投稿

YouheiSakurai
YouheiSakurai

スコア6142

test CHANGED
@@ -1,5 +1,5 @@
1
1
  ```python
2
2
 
3
- correct = lambda s: str.translate(s, str.maketrans("015", "OIS"))
3
+ correct = lambda s: s.translate(str.maketrans("015", "OIS"))
4
4
 
5
5
  ```