I have the following task:
Import the
sysmodule and create a function with a string parameter that will print the number of unique vowels in the string regardless of whether it is uppercase or lowercase.
For example:
Test 1: The argument swEet should print 1
Test 2: The argument “Aaa aeeE” should print 2
Test 3: The argument "eiOuayOI j_#Ra" should print 5
I have the following code:
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 case 1 is the only test that prints the expected output. The other two test cases, Test 2 and Test 3, do not print the correct expected result. Test 2 prints 5 rather the expected output of 4 and Test 3 prints 6 instead of the expected output of 5.