Question: I have already coded the first function for joinedList(), but I am having trouble with removePunctuation(). I was able to get it to remove all
I have already coded the first function for joinedList(), but I am having trouble with removePunctuation(). I was able to get it to remove all punctuation, but not replace with whitespace.
I would appreciate both a basic, yet inefficient solution, and a more streamlined solution to this problem. Thank you very much for the help.
*See example outputs at the bottom of the code*

def joinedList (n) # n : positive integer # It returns the list [1,2,3, , n-1, n, n, n-1, # Function body starts here , 3,2,1] Fends here def removePunctuation (s) # s : string # It replaces every charactor that is not an alphabet letter into a space, and returns it. , but at home .. (She's afraid of water)" s "She sells seashells, removePunctuation (s) - "She sel1s seashe11s but at home She s afraid of water" hint: Study string methods.py in detail. Convert s into a list, and use a for-loop including an if-block # Function body starts here ends here ### My answer key includes 11 coded lines in total. ### To check: print (joinedList (10)) # should output #[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1] s = "She sells seashells, , but at home .. (She's afraid of water)" print (removePunctuation (s)) # should output #She sells seashells but at home She s afraid of water
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
