← Back to challenges

Correct My Sentence

PythonHardsortingvalidationlanguage_fundamentalsconditionsregex

Instructions

Mubashir is not so good with the English language. He needs your help to correct his sentences.

  1. Start each sentence with an uppercase alphabet.
  2. For every uppercase letter (other than the first alphabet), you have to place a fullstop(.) followed by an empty space.
  3. There must be only one space between the words and sentences.
  4. Sentence must end with a full stop(.)
  5. Two continuous spaces are not allowed.
correct_sentences ("  mubashir loves  innokodakademija  Matt  loves  innokodakademija  ") ➞ "Mubashir loves innokodakademija. Matt loves innokodakademija."

# Remove extra spaces.
# Capitalise first character.
# Dot followed by an empty space before "Matt".
# A dot at the end.

Examples

correct_sentences ("  mubashir loves  innokodakademija  Matt  loves  innokodakademija  ") ➞ "Mubashir loves innokodakademija. Matt loves innokodakademija."

correct_sentences ("  he is an engineer He sleeps a lot") ➞ "He is an engineer. He sleeps a lot."

correct_sentences (" his english is not good Help him     Thank you") ➞ "His english is not good. Help him. Thank you."

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.