Question
Write a short script that will have the user enter in words until the word quit is entered. You will then display a sorted list
Write a short script that will have the user enter in words until the word quit is entered. You will then display a sorted list of words, and list how many vowels appear in each word, next to the word. (Hint: how can we use our string methods to make things easier for us?)
Sample output
Enter a word (quit to stop): hello again 3
Enter a word (quit to stop): again are 2
Enter a word (quit to stop): how hello 2
Enter a word (quit to stop): are how 1
Enter a word (quit to stop): you you 2
####################################
this is my code so far
vowels = 0 words = []
truth = True
while truth: word = input('Enter a word ("quit" to stop): ') words.append(word) words = list(word) for cha in words: if cha == 'a' or cha == 'e' or cha == 'o' or cha == 'i' or cha == 'u': vowels +=1 if word == 'quit': truth = False print("vowels: " + str(vowels)) print(words)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started