Python help... Suppose variable s has been assigned in this way: s = '''It was the best of times, it was the worst of times; it was the age of wisdom, it was the age of foolishness; it was the epoch of belief, it was the epoch of incredulity; it was ... ''' (The beginning of A Tale of Two Cities by Charles Dickens.) Then do the following, in order, each time and show the result (e.g., show assignment statement and result after each): (a) Write a sequence of statements that produce a copy of s, named newS, in which charactersperiod (.), comma (,), semicolon (;), andend of line (\n) have been replaced by blank spaces. (b) Remove leading and trailing blank spaces in newS (and name the new string newS). (c) Make all characters in newS lowercase (and name the new string newS). (d) Compute the number of occurrences in newS of string 'it was'. (e) Change every occurrence of was to is (and name the new string newS). (f) Split newS into a list of words and name the list listS
Python help...
Suppose variable s has been assigned in this way: s = '''It was the best of times, it was the worst of times; it was the age of wisdom, it was the age of foolishness; it was the epoch of belief, it was the epoch of incredulity; it was ... '''
(The beginning of A Tale of Two Cities by Charles Dickens.)
Then do the following, in order, each time and show the result (e.g., show assignment statement and result after each):
(a) Write a sequence of statements that produce a copy of s, named newS, in which charactersperiod (.), comma (,), semicolon (;), andend of line (\n) have been replaced by blank spaces.
(b) Remove leading and trailing blank spaces in newS (and name the new string newS).
(c) Make all characters in newS lowercase (and name the new string newS).
(d) Compute the number of occurrences in newS of string 'it was'.
(e) Change every occurrence of was to is (and name the new string newS).
(f) Split newS into a list of words and name the list listS
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images