Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Basic utility functions
Basic manipulation functions
Replacing and splitting
10. The replace() function
Summary

Instruction

Well done! Another interesting function is replace(old, new). It replaces all instances of old with new in a string. Take a look:

story = ('Anne was hungry, so she went to a restaurant. '
  'When the waiter came up to her, Anne ordered some vegetarian dishes.')
print(story.replace('Anne', 'Katherine'))

When we print the story, the protagonist's name will be changed to Katherine.

Exercise

Given an article about Pythonidae, print its contents with every sentence beginning on a new line.

Stuck? Here's a hint!

Use the replace() function to find every instance of a period followed by a space. Replace those instances with a period followed by the newline character (\n).