python: def ohno_twozero(placeholder, statement):     """     Question 1 - Regex     You are typing a personal statement but accidentally used the number 0 instead of the letter o (the two are very close on the keyboard).     After realizing this, seeing the mistake once does not bother you, but you absolutely cannot tolerate seeing it twice in a row.     Therefore, you will need to replace any WORD where '00' shows up at any point with the given placeholder.     Do not replace any NUMBER where 00 shows up. (e.g. '100' should stay as '100' and not be replaced with the placeholder).     You may assume that when '00' shows up in a word, there will be at least one letter preceding it.     Return the output string after making these changes.     THIS MUST BE DONE IN ONE LINE.     Args:     placeholder (str)     statement (str)     Returns:     str     >>> ohno_twozero('epic', "I am n0w l00king at 500 t0tal h0urs 0n Super Smash Br0s.")     "I am n0w epic at 500 t0tal h0urs 0n Super Smash Br0s."     >>> ohno_twozero('bruh', "And I w0uld have g0tten away with it t00 if it wasn't f0r all 200 0f y0u meddling kids!")     "And I w0uld have g0tten away with it bruh if it wasn't f0r all 200 0f y0u meddling kids!"     """     # pprint(ohno_twozero('epic', "I am n0w l00king at 500 t0tal h0urs 0n Super Smash Br0s."))     # pprint(ohno_twozero('bruh', "And I w0uld have g0tten away with it t00 if it wasn't f0r all 200 0f y0u meddling kids!"))

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

python:
def ohno_twozero(placeholder, statement):
    """
    Question 1 - Regex

    You are typing a personal statement but accidentally used the number 0 instead of the letter o (the two are very close on the keyboard).
    After realizing this, seeing the mistake once does not bother you, but you absolutely cannot tolerate seeing it twice in a row.

    Therefore, you will need to replace any WORD where '00' shows up at any point with the given placeholder.
    Do not replace any NUMBER where 00 shows up. (e.g. '100' should stay as '100' and not be replaced with the placeholder).
    You may assume that when '00' shows up in a word, there will be at least one letter preceding it.

    Return the output string after making these changes.

    THIS MUST BE DONE IN ONE LINE.

    Args:
    placeholder (str)
    statement (str)

    Returns:
    str

    >>> ohno_twozero('epic', "I am n0w l00king at 500 t0tal h0urs 0n Super Smash Br0s.")
    "I am n0w epic at 500 t0tal h0urs 0n Super Smash Br0s."

    >>> ohno_twozero('bruh', "And I w0uld have g0tten away with it t00 if it wasn't f0r all 200 0f y0u meddling kids!")
    "And I w0uld have g0tten away with it bruh if it wasn't f0r all 200 0f y0u meddling kids!"

    """
    # pprint(ohno_twozero('epic', "I am n0w l00king at 500 t0tal h0urs 0n Super Smash Br0s."))
    # pprint(ohno_twozero('bruh', "And I w0uld have g0tten away with it t00 if it wasn't f0r all 200 0f y0u meddling kids!"))

Expert Solution
Step 1

The Python program for the given problem is as follows:

# Import the pprint module for calling pprint() function
import pprint
# Import the re module for using the regex function
import re
# Declare the function ohno_twozero(placeholder, statement) with two parameters placeholder and statement
def ohno_twozero(placeholder, statement):
    return re.sub(r'\b\w*0{2}\w*\b(?<!\d)', placeholder, statement)
# Call and display ohno_twozero('epic', "I am n0w l00king at 500 t0tal h0urs 0n Super Smash Br0s.") function
pprint.pprint(ohno_twozero('epic', "I am n0w l00king at 500 t0tal h0urs 0n Super Smash Br0s."))
# Call and display ohno_twozero('bruh', "And I w0uld have g0tten away with it t00k if it wasn't f0r all 200 0f y0u meddling kids!") function
pprint.pprint(ohno_twozero('bruh', "And I w0uld have g0tten away with it t00k if it wasn't f0r all 200 0f y0u meddling kids!"))

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education