Here’s a problem I recently gave my students. Can you solve it using only Chapter 1 of Learn to Code by Solving Problems?
Dan’s writing a new book, but he needs a bit of help with his grammar. Correct the given sentences by adding commas in the correct locations throughout the sentence.
and
(which will not occur anywhere else in the sentence), then one more word followed by a period. Words consist only of lowercase or uppercase letters.For example, the sentence Dinner is chocolate, goldfish and mustard.
is a valid input, and so is TAs like code exams tests essays and grading.
Output the sentence with one comma after each noun (nouns in this problem are the words indicated above in the input section). Do not add or modify anything else about the given sentence.
For example, given the input TAs like code exams tests essays and grading.
, your code should output TAs like code, exams, tests, essays, and grading.
replace
to solve this problem (i.e. no lists, split
, or anything else after Chapter 1).Ruth eats apples oranges, kiwis and bananas.
Ruth eats apples, oranges, kiwis, and bananas.
Parvati reads books and code.
Parvati reads books, and code.