Question: 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

1 Expert Approved Answer
Step: 1 Unlock

sequence of characters that uses a search pattern to find ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!