Challenge: Clean Up User Input
Opgave
Swipe to start coding
Write a function that takes a sentence and returns a cleaned, formatted version.
- Remove extra spaces from the beginning and end of the sentence.
- Replace all sequences of multiple spaces between words with a single space.
- Replace every standalone "u" with "you" and "r" with "are", only when they appear as whole words.
- Capitalize the first letter of the sentence and make all other letters lowercase.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 6
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Suggested prompts:
Can you explain this in more detail?
What are the main benefits or drawbacks?
Can you give me an example?
Fantastisk!
Completion rate forbedret til 4.76
Challenge: Clean Up User Input
Stryg for at vise menuen
Opgave
Swipe to start coding
Write a function that takes a sentence and returns a cleaned, formatted version.
- Remove extra spaces from the beginning and end of the sentence.
- Replace all sequences of multiple spaces between words with a single space.
- Replace every standalone "u" with "you" and "r" with "are", only when they appear as whole words.
- Capitalize the first letter of the sentence and make all other letters lowercase.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 6
single