Assignment 12 — stringing lists
Due Monday, September 23
Advice
- If you have not yet check out the string module, we highly recommend you do so.
Program aeschylus.py
Algorithm to be followed
- Prompt and gets user-supplied text.
- Splits the user-supplied text into a list of words
- Prints the list of user-supplied words.
- Through accumulation, produces a new list whose elements are those of the user-supplied words with all occurrences of
"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 member function lets you produce a tweaked version of its string that replaces
"s"
' s with nothing? And what is nothining in this case?
- What list member function allows you to append an element to its list?
- Prints the s-less list.
- Reprints the list of user-supplied words.
Solution requirement
- Do not print anything other than what is requested.
Two sample program runs
Enter text: susie sells seashells by the seashore
['susie', 'sells', 'seashells', 'by', 'the', 'seashore']
['uie', 'ell', 'eahell', 'by', 'the', 'eahore']
['susie', 'sells', 'seashells', 'by', 'the', 'seashore']
Enter text: sleepless in Seattle
['sleepless', 'in', 'Seattle']
['leeple', 'in', 'Seattle']
['sleepless', 'in', 'Seattle']
© 2019 Jim Cohoon | Resources from previous semesters are available. |