Drop hier links of afbeeldingen om ze aan de editor toe te voegen.

Another make task, and this time the program has to look at every character of a word, one at a time.

A primary school teacher wants a simple program to help pupils find out how many vowels there are in different words. The vowels are A, E, I, O and U. Y does not count.

Your task

Write a program that:

The loop runs over the positions in the word, range(len(word)), and the slice word[i:i+1] is the character at position i. To check whether that character is a vowel you can compare it with each of the five vowels in turn, or put the five vowels in a list and use in, as you did with lists.

Converting the word first is what lets the program count a and A alike: a comparison with "A" only matches a capital letter.

The tests also check your code: a program that does not use a for loop, slicing and upper() does not pass.

The output

The question first, worded exactly like this:

Enter a word:

Then one line, where COUNT is the number of vowels in the word:

Number of vowels: COUNT

Example

Input:

banana

Output:

Enter a word:
Number of vowels: 3

Input:

Aeroplane

Output:

Enter a word:
Number of vowels: 5

A word with no vowels at all is still answered, with a count of 0: Rhythm gives Number of vowels: 0.

Ask the question with its own print, and read the answer with a bare input() on the next line, rather than passing the question to input(...). The question is part of the output that is checked here, so its spelling, capital letters and punctuation count.

Help! My code doesn't work!

Make sure that you check for the following things:

  • The result of upper() is stored, as in word = word.upper(). On its own, word.upper() changes nothing.
  • The count is created before the loop and given the value 0.
  • The line that adds to the count is inside the if, which is inside the loop.
  • The print of the count is not indented, so it runs once, after the loop.
  • The count is wrapped in str() before it is joined onto the text.
  • The loop visits every position: range(len(word)), not range(len(word) - 1).