Your code initially confused me quite a bit, as besides not being in a code block (and thus not only hard to follow, but impossible to parse without guessing where the syntactically critical indentation was supposed to go), the names were not only not very descriptive (
counterss all meaning different things), but also in some cases actively confusing, e.g.
numberOfVouls is not, as its name would imply, a number at all, but rather a list of all the vowels, which was only obvious after carefully picking through your code. You might want to rename it something like
In any case, there is one potential issue with @sandraC 's solutions—while not explicitly specified in your question (in the future, remember to describe what exactly your desired output is, with examples), I would presume you only want to print the unique values used, not every vowel (i.e. for the sentance
“Spam spam eggs and spam” you’d want to print
Vowels are: a, e not
Vowels are: a, a, e, a, a. If that’s the case, you can just call
set() on your
vowelsFound list prior to printing it to make it a set, which will only retain the unique vowels, or just make it a set to begin with).
However, you can make your code much shorter, simpler, more readable and more efficient by redesigning it (or “refactoring”, as we call it) a bit. Instead of iterating through your sentence to count the number of each character, keeping track of a bunch of counters, and then iterating through again to get the unique vowels, I suggest just iterating through it once and adding each character found its respective list based on its type. Then, you can get the count when you need it by calling
len() on the list, all the vowels (or consonents, etc) by printing the list, and the unquie vowels by casting the list to a set and printing that.
Also, you aptly used
str.isalpha() to check for non-vowel letters, but you can equally well use
str.isdecimal() to check for decimal numbers characters rather than hardcoding them (or using
string.digits, which is a build-in iterable string of the ASCII digits). And instead of a hardcoded check for only space (
" "), use
Assuming you have
ALL_VOWELS = set("aeiou")
your_sentence = input("Enter your sentence here: ").lower()
and create your lists like so,
digits_used = 
vowels_used = 
consonants_used = 
specials_used = 
you could then loop through your sentence like this:
for char in your_sentence:
elif char in ALL_VOWELS:
Print the counts like this:
print("Number of vowels:", len(vowels_used))
# Etc for the rest
and then, to print the specific, unique vowels used, just do this:
print("Vowels are: ", ", ".join(set(vowels_used)))
That’s shorter, simpler and much easier to keep track of than two loops and lots of counters, and also lets you easily modify your code to print the other character types as well, get counts of each specific vowel, etc.
To note, aside from @sandraC 's excellent advice to use more descriptive names, which is indeed very important (and more so than the style you use), per the PEP 8 standard and widely used Python convention,
sentence_case is used for variable names (and function/method names), while (upper) CamelCase is used for class names (i.e.