# -*- coding: utf-8 -*-
"""
Created on Sat Oct 19 12:37:04 2019
@author: shark
"""
print("This code should compute the number of vowels in a string.")
input_string = input( "Enter a string (e.g. your name): " )
a = "a"
A = "A"
e = "e"
E = "E"
i = "i"
I = "I"
o = "o"
O = "O"
u = "u"
U = "U"
acount = 0
ecount = 0
icount = 0
ocount = 0
ucount = 0
if a or A in input_string :
acount = acount + 1
if e or E in input_string:
ecount = ecount + 1
if i or I in input_string :
icount = icount + 1
if o or O in input_string :
ocount = ocount + 1
if u or U in input_string :
ucount = ucount + 1
number_of_vowels = acount+ecount+icount+ocount+ucount
print( "The number of vowels in the string is:", number_of_vowels )
(b) Number of different vowels in a string
To answer this question you need to write code that will determine the number of different vowels in a string input by the user. By "different vowels" we mean that if the same vowel occurs more than once it is only counted once. Moreover, small and captial versions of the same letter do NOT count as different vowels. Thus, the number given as the answer will always be from 0 to 5 (inclusive).
Examples | |
---|---|
INPUT | OUPUT |
yyyykz | 0 |
A cat sat on a mat | 2 |
Abracadabra | 1 |
Eutopia | 5 |