Python code to complete: import re def sget(string): # write your code here Complete the function sget
Fantastic news! We've Found the answer you've been seeking!
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 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.
Related Book For
Discrete Mathematics and Its Applications
ISBN: 978-0073383095
7th edition
Authors: Kenneth H. Rosen
Posted Date: