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/opZn 著作权归作者所有。请勿转载和采集!