Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6a95077

Browse files
Create Solution.py
1 parent 1b8d3de commit 6a95077

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution:
2+
def countVowel(self, s):
3+
count = 0
4+
for ch in s:
5+
if ch=='a' or ch == 'A' or ch == 'e' or ch == 'E' or ch == 'i' or ch == 'I' or ch == 'o' or ch == 'O' or ch == 'u' or ch == 'U':
6+
count = count + 1
7+
else:
8+
continue
9+
return count
10+
def halvesAreAlike(self, s: str) -> bool:
11+
l = len(s)
12+
n = l//2
13+
s1 = s[:n]
14+
s2 = s[n:]
15+
16+
m = self.countVowel(s1)
17+
n = self.countVowel(s2)
18+
19+
if m==n:
20+
return True
21+
else:
22+
return False

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /