Advertisement
hacaplus

number of vowels

Oct 24th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. def numVowels(string):
  2.     vowels = 0
  3.     consonants = 0
  4.     for char in string:
  5.         if char in "aeiouAEIOU":
  6.             vowels +=1
  7.     return vowels
  8.  
  9. def equalVowels(string):
  10.     for j in xrange(len(string), 1, -1):
  11.         for i in xrange(0, len(string), 1):
  12.             my_substring = string[i:i+j]
  13.             num_vowels = numVowels(my_substring)
  14.             if (num_vowels == len(my_substring) - num_vowels):
  15.                 return my_substring
  16.     return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement