回答編集履歴
4
空行削除
test
CHANGED
@@ -26,8 +26,6 @@
|
|
26
26
|
|
27
27
|
lis = [*map(len, ''.join(' a'[s == 'a'] for s in st).split())]
|
28
28
|
|
29
|
-
|
30
|
-
|
31
29
|
print(lis)
|
32
30
|
|
33
31
|
```
|
3
ショートバージョンのバグ修正
test
CHANGED
@@ -24,7 +24,9 @@
|
|
24
24
|
|
25
25
|
st = ['a', 'a', '_', '_', 'a', '_', 'a', 'a', 'a']
|
26
26
|
|
27
|
-
lis = [*map(len, ''.join(' a'[s == 'a'] for s in st).split())]
|
27
|
+
lis = [*map(len, ''.join(' a'[s == 'a'] for s in st).split())]
|
28
|
+
|
29
|
+
|
28
30
|
|
29
31
|
print(lis)
|
30
32
|
|
2
変数名変更
test
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
|
25
25
|
st = ['a', 'a', '_', '_', 'a', '_', 'a', 'a', 'a']
|
26
26
|
|
27
|
-
lis = [*map(len, ''.join(' a'[
|
27
|
+
lis = [*map(len, ''.join(' a'[s == 'a'] for s in st).split())])]
|
28
28
|
|
29
29
|
print(lis)
|
30
30
|
|
1
別の書き方追加
test
CHANGED
@@ -13,3 +13,19 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
を付け加えるのはいかがでしょう?
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
ちなみに、こんな書き方もできます。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```python
|
24
|
+
|
25
|
+
st = ['a', 'a', '_', '_', 'a', '_', 'a', 'a', 'a']
|
26
|
+
|
27
|
+
lis = [*map(len, ''.join(' a'[item == 'a'] for item in st).split())]
|
28
|
+
|
29
|
+
print(lis)
|
30
|
+
|
31
|
+
```
|