编写函数countVowelsstring返回字符串string中元音字母的个数python编写
def countVowels(string): vowels = "aeiouAEIOU" count = 0 for char in string: if char in vowels: count += 1 return count
example usage
print(countVowels("Hello world")) # output: 3 print(countVowels("Python programming")) # output: 4
原文地址: https://www.cveoy.top/t/topic/fK7z 著作权归作者所有。请勿转载和采集!