Question: Use Python to create a function cleanupstring(S) to clean up the spaces in a sentence S. The sentence may have extra spaces at the front

Use Python to create a function cleanupstring(S) to "clean up" the spaces in a sentence S. The sentence may have extra spaces at the front and/or at the end and/or between words. The subroutine returns a new version of the sentence without the extra spaces. That is, in the new string, the words should be the same but there should be no spaces at the start, only one space between each word and no spaces at the end. In the main program, you will have the user input the string to be "cleaned", call the cleanupstring function and print out the result This program is about you writing code to search through a string to find words and so you are not allowed to use the split function in Python. You can solve this problem with the basic capabilities of if and while statements and the string operations of len and concatentation. For example: if the input is "Hello to the world" then the output should be: "Hello to the world" Make sure your program is general enough to work for other possible sentences
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
