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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 2PP: (Mechanics) The deflection at any point along the centerline of a cantilevered beam, such as the one...
icon
Related questions
Question

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

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning