Question: Parameter: One parameter which is expected to be a string holding a sentence. Description: This function should look at each character in the parameter string.

Parameter: One parameter which is expected to be a string holding a sentence.
Description: This function should look at each character in the parameter string. If the character is a period, comma, exclamation point, or dash, accumulate it in a result string. Return the string of accumulated punctuation. You should refer to the Lecture 7 accumulation loop that found 'a' in a string as an example of building up a string solution.
Example: collect_punctuation("Hey! How are you? Nice - see you later.")should return "!-.". Note that it did not include the "?" as it is not punctuation the function looks for.
Restrictions: You may not use the in keyword and a list collection of punctuation to test if a character is punctuation, or related approaches. You can use in with a for loop, like for letter in sentence. You cannot also use things like regex or other one line solutions. Write an accumulation loop. If you do not know what these other approaches mean, it is because we have not discussed this yet.

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 Programming Questions!