回答編集履歴

2

説明追記

2020/07/03 21:45

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -1,4 +1,32 @@
1
+ > ①['', 'Keep', 'on', 'asking',~~(中略)~~'opened', '', '']の部分と、その下の行にある12を出力したくない
2
+
3
+
4
+
5
+ printを削除
6
+
7
+
8
+
9
+ > ②単語をアルファベット順に出力したい(現状はその単語が登場した順番)
10
+
11
+
12
+
1
- こうすか?
13
+ sortedソート
14
+
15
+
16
+
17
+ > ③大文字のKeepと小文字のkeepが混在しているので、すべて小文字のkeepに統一したい
18
+
19
+
20
+
21
+ .lower() で小文字に変換
22
+
23
+
24
+
25
+ > ④文字数が54とずれているので、42となるようにしたいこうですか?
26
+
27
+
28
+
29
+ 空文字 '' を累算しているため。.split() で複数の空白文字をひとまとまりにして分割。
2
30
 
3
31
 
4
32
 

1

strip削除

2020/07/03 21:45

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- words = text.replace(";" , " ").replace("," , " ").replace("`" , " ").replace("." , " ").lower().strip().split()
27
+ words = text.replace(";" , " ").replace("," , " ").replace("`" , " ").replace("." , " ").lower().split()
28
28
 
29
29
  counter = Counter(words)
30
30