You are on page 1of 1

#define main

def main():

#declare variables
userStr = ''
numVowels = 0.0
numConson = 0.0

userStr = input('Please enter a string: ')

numVowels = getVowels(userStr)

numConson = getConsonants(userStr)

print(f'The number of vowels in the string is {numVowels:.0f}.')


print(f'The number of consonants in the string is {numConson:.0f}.')
#-------------------------------------------
#define functions
def getVowels(stringU):

#test - print(stringU)
vowelCount = 0.0

for char in stringU:


if char == 'a' or char == 'A' or char == 'e' or char == 'E' or char == 'i'
or char == 'I' or char == 'o' or char == 'O' or char == 'u' or char == 'U':
vowelCount += 1
return vowelCount

def getConsonants(stringU):

#test - print(stringU)
consonCount = 0.0
vowNum = 0.0

for char in stringU:


if char.isalpha():
consonCount += 1
#test - print(consonCount)
if char == 'a' or char == 'A' or char == 'e' or char == 'E' or char == 'i'
or char == 'I' or char == 'o' or char == 'O' or char == 'u' or char == 'U':
vowNum += 1

#test - print(vowNum)
#test - print(len(stringU))
consonCount = consonCount - vowNum

return consonCount
#-------------------------------------------
#call main
if __name__ == '__main__':
main()

You might also like