Assignment 12 — stringing lists
Program aeschylus.py
Due Tuesday, September 22
Problem
- Get a list of words from the user, and determine the corresponding list of words with all occurrences of lower case character
's'
removed.
- Along the way doing so,
- Print the input as a list of strings with the
's'
characters still present.
Advice
- Follow my advice and suggestions, it well help you greatly in the longer term.
- If you have not yet check out the string module, we highly recommend you do so.
- If you have not yet also check out the lists module, we highly recommend you do so.
Suggested algorithm
- Prompt and get user-supplied text.
- Split the user-supplied text into a list of words
- Print that list of words.
- Through accumulation produce a new list, where its elements correspond to the user-supplied words with all occurrences of lower case
's'
removed. To do this, you need to be able to answer the following.
- What type of object is the accumulator? The answer tells you how to set its initial value.
- Where should the accumulator be initialized? Before, in, or after the loop?
- What string function lets you produce a tweaked version of its string that replaces all occurence of lower case
's'
with nothing?
- What is the nothing string?
- What list function allows you to append an element to its list?
- Print the lower case
's'
-less list.
Note
- Do not print anything other than what is requested.
Two possible program runs
Enter text: susie sells seashells by the seashore
['susie', 'sells', 'seashells', 'by', 'the', 'seashore']
['uie', 'ell', 'eahell', 'by', 'the', 'eahore']
Enter text: sleepless in Seattle
['sleepless', 'in', 'Seattle']
['leeple', 'in', 'Seattle']
Bust of Aeschylus
© 2020 Jim Cohoon | Resources from previous semesters are available. |