質問編集履歴
5
can110様の回答を自分なりに解釈して作ってみました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
コード
|
4
4
|
def kazoeru(bunsho, shiin):
|
5
5
|
countC=0
|
6
|
+
countV=0
|
6
7
|
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
7
8
|
for i in bunsho:
|
8
9
|
if i in alphabet_list:
|
@@ -10,24 +11,19 @@
|
|
10
11
|
if i not in my_list:
|
11
12
|
shiin=True
|
12
13
|
countC+=1
|
13
|
-
return(countC)
|
14
|
-
bunsho=("lundberg backdrop us phd formate polemic")
|
15
|
-
print(kazoeru(bunsho, True))
|
16
14
|
|
17
|
-
def kazoeru(bunsho, shiin):
|
18
|
-
|
15
|
+
else:
|
19
|
-
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
20
|
-
for j in bunsho:
|
21
|
-
if j in alphabet_list:
|
22
|
-
my_list =["a", "e", "i", "o", "u"]
|
23
|
-
if j in my_list:
|
24
16
|
shiin=False
|
25
17
|
countV+=1
|
18
|
+
if shiin==True:
|
19
|
+
return(countC)
|
20
|
+
else:
|
26
|
-
|
21
|
+
return(countV)
|
27
22
|
|
28
23
|
|
29
24
|
bunsho=("but thy eternal summer shall not fade")
|
25
|
+
print(kazoeru(bunsho, True))
|
26
|
+
print(kazoeru(bunsho, False))
|
30
27
|
|
31
|
-
print(kazoeru(bunsho, False))
|
32
28
|
```
|
33
29
|
よろしくお願いします。
|
4
ご指摘いただきまして、ありがとうございます。コピペしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,31 +1,33 @@
|
|
1
1
|
文章内の母音と子音を分けて各総数を出す式を作ってみたのですが、文章によっては正しく答えが出せないのですが、バグが見つけられません。
|
2
2
|
```python3
|
3
3
|
コード
|
4
|
-
|
5
4
|
def kazoeru(bunsho, shiin):
|
6
5
|
countC=0
|
7
6
|
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
8
7
|
for i in bunsho:
|
9
8
|
if i in alphabet_list:
|
10
|
-
my_list =["a","e","i","o","u"]
|
9
|
+
my_list =["a", "e", "i", "o", "u"]
|
11
10
|
if i not in my_list:
|
12
11
|
shiin=True
|
13
|
-
countC
|
12
|
+
countC+=1
|
14
13
|
return(countC)
|
15
|
-
bunsho=("
|
14
|
+
bunsho=("lundberg backdrop us phd formate polemic")
|
16
|
-
print(kazoeru(bunsho, True)
|
15
|
+
print(kazoeru(bunsho, True))
|
17
16
|
|
18
17
|
def kazoeru(bunsho, shiin):
|
19
18
|
countV=0
|
20
19
|
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
21
20
|
for j in bunsho:
|
22
21
|
if j in alphabet_list:
|
23
|
-
|
22
|
+
my_list =["a", "e", "i", "o", "u"]
|
24
|
-
|
23
|
+
if j in my_list:
|
25
|
-
|
24
|
+
shiin=False
|
26
|
-
|
25
|
+
countV+=1
|
27
26
|
return(countV)
|
27
|
+
|
28
|
+
|
28
|
-
bunsho=("
|
29
|
+
bunsho=("but thy eternal summer shall not fade")
|
30
|
+
|
29
|
-
print(kazoeru(bunsho, False)
|
31
|
+
print(kazoeru(bunsho, False))
|
30
32
|
```
|
31
33
|
よろしくお願いします。
|
3
```を最後の行の下に入れてみました。これで合ってますでしょうか?
title
CHANGED
File without changes
|
body
CHANGED
@@ -27,6 +27,5 @@
|
|
27
27
|
return(countV)
|
28
28
|
bunsho=("shall i compare thee to a summer's day?")
|
29
29
|
print(kazoeru(bunsho, False)
|
30
|
-
|
30
|
+
```
|
31
|
-
|
32
31
|
よろしくお願いします。
|
2
直してみました。子音と母音の各々の総数を一つの関数で出したかったのですが、うまくいかなかったので、二つに分けてしまいました。本当は一つにまとめるのが理想です。Falseの時は正解になるのですが、Tru
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,31 +1,32 @@
|
|
1
1
|
文章内の母音と子音を分けて各総数を出す式を作ってみたのですが、文章によっては正しく答えが出せないのですが、バグが見つけられません。
|
2
2
|
```python3
|
3
3
|
コード
|
4
|
-
```def kazoeru(bunsho, shiin):
|
5
|
-
countC=0
|
6
|
-
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
7
|
-
for i in bunsho:
|
8
|
-
if i in alphabet_list:
|
9
|
-
my_list =["a","e","i","o","u"]
|
10
|
-
if i not in my_list:
|
11
|
-
shiin=True
|
12
|
-
countC +=1
|
13
|
-
return(countC)
|
14
|
-
bunsho=("shall i compare thee to a summer's day?")
|
15
|
-
print(kazoeru(bunsho, True)
|
16
4
|
|
17
|
-
|
5
|
+
def kazoeru(bunsho, shiin):
|
18
|
-
|
6
|
+
countC=0
|
19
|
-
|
7
|
+
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
20
|
-
|
8
|
+
for i in bunsho:
|
21
|
-
|
9
|
+
if i in alphabet_list:
|
22
|
-
|
10
|
+
my_list =["a","e","i","o","u"]
|
23
|
-
|
11
|
+
if i not in my_list:
|
24
|
-
|
12
|
+
shiin=True
|
25
|
-
|
13
|
+
countC +=1
|
26
|
-
|
14
|
+
return(countC)
|
27
|
-
|
15
|
+
bunsho=("shall i compare thee to a summer's day?")
|
28
|
-
|
16
|
+
print(kazoeru(bunsho, True)
|
29
|
-
```
|
30
17
|
|
18
|
+
def kazoeru(bunsho, shiin):
|
19
|
+
countV=0
|
20
|
+
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
21
|
+
for j in bunsho:
|
22
|
+
if j in alphabet_list:
|
23
|
+
my_list =["a","e","i","o","u"]
|
24
|
+
if j in my_list:
|
25
|
+
shiin=False
|
26
|
+
countV +=1
|
27
|
+
return(countV)
|
28
|
+
bunsho=("shall i compare thee to a summer's day?")
|
29
|
+
print(kazoeru(bunsho, False)
|
30
|
+
|
31
|
+
|
31
32
|
よろしくお願いします。
|
1
操作が間違っていたようで、申し訳ありません!これで見えますでしょうか?
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,30 +1,31 @@
|
|
1
1
|
文章内の母音と子音を分けて各総数を出す式を作ってみたのですが、文章によっては正しく答えが出せないのですが、バグが見つけられません。
|
2
2
|
```python3
|
3
3
|
コード
|
4
|
-
def kazoeru(bunsho, shiin):
|
4
|
+
```def kazoeru(bunsho, shiin):
|
5
|
-
|
5
|
+
countC=0
|
6
|
-
|
6
|
+
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
7
|
-
|
7
|
+
for i in bunsho:
|
8
|
-
|
8
|
+
if i in alphabet_list:
|
9
|
-
|
9
|
+
my_list =["a","e","i","o","u"]
|
10
|
-
|
10
|
+
if i not in my_list:
|
11
|
-
|
11
|
+
shiin=True
|
12
|
-
|
12
|
+
countC +=1
|
13
|
-
|
13
|
+
return(countC)
|
14
|
-
bunsho=("shall i compare thee to a summer's day?")
|
14
|
+
bunsho=("shall i compare thee to a summer's day?")
|
15
|
-
print(kazoeru(bunsho, True)
|
15
|
+
print(kazoeru(bunsho, True)
|
16
16
|
|
17
|
-
def kazoeru(bunsho, shiin):
|
17
|
+
def kazoeru(bunsho, shiin):
|
18
|
-
|
18
|
+
countV=0
|
19
|
-
|
19
|
+
alphabet_list=("abcdefghijklmnopqrstuvwxyz")
|
20
|
-
|
20
|
+
for j in bunsho:
|
21
|
-
|
21
|
+
if j in alphabet_list:
|
22
|
-
|
22
|
+
my_list =["a","e","i","o","u"]
|
23
|
-
|
23
|
+
if j in my_list:
|
24
|
-
|
24
|
+
shiin=False
|
25
|
-
|
25
|
+
countV +=1
|
26
|
-
|
26
|
+
return(countV)
|
27
|
-
bunsho=("shall i compare thee to a summer's day?")
|
27
|
+
bunsho=("shall i compare thee to a summer's day?")
|
28
|
-
print(kazoeru(bunsho, False)
|
28
|
+
print(kazoeru(bunsho, False)
|
29
|
+
```
|
29
30
|
|
30
31
|
よろしくお願いします。
|