Question: Write a Python program that does following: ( 1 ) Prompt the user to enter a string of their choosing. Store the text in a
Write a Python program that does following:
Prompt the user to enter a string of their choosing. Store the text in a string. Output the string.
Enter a sample text:
we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
Implement a printmenu function, which has a string as a parameter, outputs a menu of user options for analyzingediting the string, and returns the user's entered menu option and the sample text string which can be edited inside the printmenu function Each option is represented by a single character.
If an invalid character is entered, continue to prompt for a valid choice.
Hint: Implement the Quit menu option before implementing other options. Call printmenu in the main section of your code. Continue to call printmenu until the user enters q to Quit.
Ex:
MENU
c Number of nonwhitespace characters
w Number of words
f Fix capitalization
r Replace punctuation
s Shorten spaces
q Quit
Choose an option:
Implement the getnumofnonWScharacters function. getnumofnonWScharacters has a string parameter and returns the number of characters in the string, excluding all whitespace. Call getnumofnonWScharacters in the printmenu function.
Ex:
Number of nonwhitespace characters:
Implement the getnumofwords function. getnumofwords has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call getnumofwords in the printmenu function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
