text input ("Enter text: ") %3D start_char = input("Enter starting character marker: ") end_char = input("Enter ending character marker: ") output_str =" ignore = False # True means the current char is between the markers i = 0 while i < len(text): if if if i+= 1 print("The new string is:", output_str) ignore = True output_str += text[i] ignore = False not ignore text[i] == end_ text[i] == start_char
text input ("Enter text: ") %3D start_char = input("Enter starting character marker: ") end_char = input("Enter ending character marker: ") output_str =" ignore = False # True means the current char is between the markers i = 0 while i < len(text): if if if i+= 1 print("The new string is:", output_str) ignore = True output_str += text[i] ignore = False not ignore text[i] == end_ text[i] == start_char
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![text =
input("Enter text: ")
start_char
input("Enter starting character marker: ")
%3D
end_char
input("Enter ending character marker: ")
output_str
ignore
False
# True means the current char is between the markers
%3D
i = 0
%3D
while i < len(text):
if
if
if
i+= 1
print("The new string is:", output_str)
ignore = True
output_str += text[i]
ignore = False
not ignore
text[i] == end_char
%3D
text[i] == start_char](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F0bf2a09b-e4db-477d-a3dc-9ff630d2d5f6%2F77ddf954-4d9c-46a5-9104-dc703e70a9b0%2Fsukanl_processed.png&w=3840&q=75)
Transcribed Image Text:text =
input("Enter text: ")
start_char
input("Enter starting character marker: ")
%3D
end_char
input("Enter ending character marker: ")
output_str
ignore
False
# True means the current char is between the markers
%3D
i = 0
%3D
while i < len(text):
if
if
if
i+= 1
print("The new string is:", output_str)
ignore = True
output_str += text[i]
ignore = False
not ignore
text[i] == end_char
%3D
text[i] == start_char

Transcribed Image Text:We want to create a program that reads a string and removes from it the characters between two marker characters. For
example for the input text:
(to buy) We need to buy (i) milk, (ii) eggs, (iii) flour, and (iv) sugar.
And using "(" and ")" as the starting and ending markers, the program should output:
We need to buy
milk, eggs,
flour, and
sugar.
Notice that the number of characters between the markers, and the number of markers present in the string may vary.
We will assume that if a starting marker appears in the input text, its corresponding ending marker is also present in the string.
Approach: The idea is to copy characters from the input text to an output string variable as long as we have not found the
starting marker. From that point on, we ignore the characters in the input text until we find the ending marker. Once we find the
ending marker, we resume copying characters to the output string variable, and the process repeats.
Drag into the placeholders below the appropriate code blocks needed to make the program work correctly.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY