Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Python!!! Write a function splitter that takes a string as an argument and

ID: 3793847 • Letter: U

Question

Using Python!!! Write a function splitter that takes a string as an argument and then returns the new version of that string. The original string that will be passed to the function consists of a sentence in which all of the words are run together but the first character of each word is uppercase. The returned version changes the sentence so that the words are separated by spaces and only the first word starts with an uppercase letter. For example, if StopAndSmellTheRoses. is passed to this functions, the function returns Stop and smell the roses.

Explanation / Answer

def splitter(s):
l = len(s)
returnString = ""
for i in range(l):
if i != 0:
if s[i] >='A' and s[i] <= 'Z':
returnString = returnString + " "
returnString = returnString+ s[i].lower()
else:
returnString = returnString+s[i]
else:
returnString = returnString+s[i]
  
return returnString;
  
print(splitter("StopAndSmellTheRoses"))

OUtput:

sh-4.3$ python3 main.py                                                                                                                                                                                                                                                  

Stop and smell the roses

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote