Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python code to complete: import re def sget(string): # write your code here Complete the function sget that will search an input string and find

Python code to complete:

import re
def sget(string):
# write your code here


Complete the function sget that will search an input string and find all strings beginning with either 'c', 'd', or 'e'. From this subset of strings, a new list of strings will be returned that only contain the digits '45'.

For example, if the input string is:

s='a1234 b2345 c3456 d4567 e5678 f6789 g0000 h0001'


then the returned string will be:

['c3456', 'd4567']

Regular expressions and the findall method could prove useful for this problem.


Step by Step Solution

3.42 Rating (146 Votes )

There are 3 Steps involved in it

Step: 1

sequence of characters that uses a search pattern to find ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete Mathematics and Its Applications

Authors: Kenneth H. Rosen

7th edition

0073383090, 978-0073383095

More Books

Students also viewed these Programming questions

Question

What is the difference between a direct cost and overhead?

Answered: 1 week ago