# [Leet Code] Determine if String Halves Are Alike

`Input: s = "book"Output: trueExplanation: a = "bo" and b = "ok". a has 1 vowel and b has 1 vowel. Therefore, they are alike.`
`Input: s = "textbook"Output: falseExplanation: a = "text" and b = "book". a has 1 vowel whereas b has 2. Therefore, they are not alike.Notice that the vowel o is counted twice.`
`Input: s = "MerryChristmas"Output: false`
`Input: s = "AbCdEfGh"Output: true`
`class Solution(object):    def halvesAreAlike(self, s):        """        :type s: str        :rtype: bool        """        vowels = ["a","e", "i", "o", "u"]        first_half = 0        answer = 0        for i in range(len(s)):            if i == len(s) / 2:                first_half = answer                answer = 0            if s[i].lower() in vowels:                answer += 1        print answer        return first_half == answer`

--

--

## More from Matthew Boyd

Learning, and posting my findings!

Love podcasts or audiobooks? Learn on the go with our new app.