Lab Assignment | Count vowels
Write a program that will use a while loop to count and display the number of vowels in the string provided as input by the end-user.
This program will consider the letters a, e, i, o, and u (both upper and lower case) to be vowels. The user may enter a single word, a sentence, a paragraph, or nothing at all as input. Be sure to test each possibility.
Python 3 please!
///Program to count the number of vowels in a string that user entered.
def string(sentence):
count = 0
sentence = sentence.lower()
i = 0
///Using while loop
while (i < len(sentence)):
if sentence[i] in ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']:
count += 1
i += 1;
return count
if __name__ == '__main__':
userInput = str(input("No of Vowels in the String user entered is: "))
count = string(userInput)
print('Vowel Count: ',count)
Get Answers For Free
Most questions answered within 1 hours.