''' Purpose: determine the length and number of vowels of a user-specified word ''' # HELPFUL CONSTANT VOWELS = 'aeiou' # get the input reply = input( 'Enter a word: ' ) # clean it up word = reply.strip() #<--- removes leading and trailing whitespace # how will we check the actual letters without caring about upper/lowercase? word = word.lower() # Now the word is in lowercase and we can ignore uppercase (in case the user gives us weird input) # ^ This is called canonical form # determine and report its length n = len( word ) print( "length:", n ) # determine and report the total of the number of occurrences of each of the vowels total_vowels = 0 for vowel in VOWELS: # for each character in the string VOWELS. vowel becomes each character on each loop #print( vowel ) # determine the number of occurrences of vowel in word occurrences_of_vowel = word.count(vowel) # print( vowel, occurrences_of_vowel ) # print statements in loops is good for debugging (take them out before you submit) # add the number of occurrences to the total total_vowels = total_vowels + occurrences_of_vowel #<-- this is called accumulation. # Since we're counting a total, our accumulator (total_vowels) starts at 0 print( "vowels:", total_vowels )