Count the Vowel
From CompSciWiki
Back to the Program-A-Day homepage
Problemcount the number of vowels in a string given by the user |
String Methods and DebuggingSideSection goes here. | |
---|---|---|
SolutionFirst, we need 3 variables: done = False vowelCount = 0
#get the input from user input = raw_input("Enter a sentence") if input != ' ': Then we need to check the vowel input = input.lower() for char in inputs: #//check if it's a vowel if char == 'a' : Then we need to use while loop to print the output while(!done): (...) #output result print '\nVowel count: %d\nVowel percentage: %d%%' % \ (vowelCount, vowelCount * 100 / leng(input)) Now we've done. You should write a complete program. | ||
Code |