I have been 'flagged' for posting a duplicate question. However, my question was not the same, as the other coder was asking how to "count how many occurrences there are of specific characters in a string". My output was not counting the occurrences of specific characters, but counting a total of specific characters (all vowels) in the string. For example the other guy was looking for the output to be:
A:1 E:6 I:2
I was also looking for a total of the numbers, so my output should be: 9
(granted we are speaking about the same string in both codes)."
I have created a piece of code but for some reason it is counting all letters, not just the vowels. I cannot figure out what part I went wrong at.
vowels = 'a', 'e', 'i', 'o', 'u'
ip_str = raw_input("Enter a string: ")
ans = str(raw_input)
count = (0)
for letters in ans:
if letters in vowels:
count += 1
print str(count)