创建一个名为countVowels的程序.py的函数接收字符串,然后打印字符串中唯一元音的数量(不管是大写还是小写).
countVowels.py
import sys
def count_vowels(args):
vowels = set()
for arg in args:
for char in arg:
if char.lower() in 'aeiou':
vowels.add(char)
return len(vowels)
print(count_vowels(sys.argv[1:]))
Test Cases
python3 countVowels.py Data
python3 countVowels.py 'Python Python'
python3 countVowels.py 'eiOuayOI j_#Ra'
The following is the error message displayed:
Traceback (most recent call last):
File "countVowels.py", line 14, in <module>
count_vowels(args)
NameError: name 'args' is not defined