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