''' 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 reply = reply.strip() # Remove leading and trailing whitespace from string word = reply.lower() # .lower() will convert all characters in the string to lowercase # We convert to lowercase since we check for lowercase vowels! # determine and report its length word_length = len ( word ) # Remember that len( s ) finds length of a string! # determine and report the total of the number of occurrences of each of the vowels nbr_of_vowels = 0 # We are accumulating a number so we wanna initialize it with 0. for v in VOWELS: # We are looping through each vowel nbr_vs = word.count( v ) # So this is counting up the number of times the v we are on occurs print( v, nbr_vs ) nbr_of_vowels = nbr_of_vowels + nbr_vs print(nbr_of_vowels) # Remember that v changes to a new vowel every time we run through the loop, # count up the number of times that vowel occurs and add that count to our # total (accumulator), nbr_of_vowels so that we have the total from each time # nbr_vs changes. # So why do we use an accumulator? Because we wanna reassign and update a value # so that we don't lose the value of nbr_of_vowels.