Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Quick recap
Indexing and slicing
Summary
17. Quiz project

Instruction

We've prepared a small project to test your skills.

Exercise

Anne loves cooking, and she tries out various recipes from the Internet. Sometimes, though, she finds recipes that are written as a single paragraph of text. For instance:

Cut a slit into the chicken breast. Stuff it with mustard, mozzarella and cheddar. Secure the whole thing with rashers of bacon. Roast for 20 minutes at 200C.

When you're in the middle of cooking, such a paragraph is difficult to read. Anne would prefer an ordered list, like this:

  1. Cut a slit into the chicken breast.
  2. Stuff it with mustard, mozzarella and cheddar.
  3. Secure the whole thing with rashers of bacon.
  4. Roast for 20 minutes at 200C.

Write a Python script that accepts a recipe string from the user ('Paste your recipe: ') and prints an ordered list of sentences, just like in the example above.

Each sentence of both the input and output should end with a single period.

Stuck? Here's a hint!

The general algorithm should look as follows:

  1. Create a new, empty string and a counter variable.
  2. Iterate over the recipe.
    1. If you find a full stop, add it to the new string alongside:
      • a new line character \n.
      • the counter value.
      • a space.
      Add one to the counter.
    2. If you find anything other than a full stop, simply add it to the final string.

You will also need to think about handling the first and last numbers in the list. We'll leave this part to you!