Question: In a python assignment need some help of writing a program that uses a method called displayMenu to display a menu like the following: Enter

In a python assignment need some help

of writing a program that uses a method called displayMenu to display a menu like the following:

Enter 1 to convert a string to uppercase Enter 2 to convert a string to lowercase Enter 3 to count the number of words in a string Enter 4 to count the number of vowels in a string Enter 5 to exit

After the user enters their choice, ask them to enter the string. Call the variable user_string, and use the len() method to prevent the user from entering an empty string. The user should enter a new string every time they make another choice. The program should loop until the user enters 5 to exit. Use the format() method to concatenate the output for display after each choice. The display should show the users original string and the result of their choice in a neat and meaningful manner.

For choice 1, use the upper() method to convert the string to uppercase. For choice 2, you should use the lower() method. For choice 3, use the split() method to split the string on spaces and store it in a list called user_list. Use the len() method to get the length of the list. For choice 4 you will need to create a variable called count to store the number of vowels in. You will need to make sure that you count upper and lowercase vowels by using the upper() or lower() method. Use a variable called vowels to store the vowels in. You will need a for loop to iterate through the users string and examine each character to determine exactly how many vowels are contained in the string. Inside of the for loop, use an if statement that contains the find() method to check for the characters contained in the vowels variable in the users string.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!