Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a. extract_num(s, begin, end) The trickiest part of this problem is this: we have found one or more digits in a string, and we need

image text in transcribed
image text in transcribed
a. extract_num(s, begin, end) The trickiest part of this problem is this: we have found one or more digits in a string, and we need to extract that number properly or decide to omit it. The extract_num() function is decomposed out to focus on that sub-problem. def extract_num(s, begin, end) : Given string s, and "begin" is the index of the first of one or more digits, and "end" is the index one beyond the last digit. Parse out and return the int value of the number, accounting for possible 's' and '*'. Return -1 if the number should be skipped. >>> extract_num('xx123$', 2, 5) 321 One test is provided. Add tests so there are at least five tests. Test varying numbers of digits, with and without' and 'S'. It is easier to build and perfect extract_num in isolation here vs. in the midst of processing a whole file. edef extract nuns, begin, end): # Given string s, and "begin" is the index of the first of one or more digits, and "end" is the index one beyond the last digit. Parse out and return the int value of the number, accounting for possible "s' and a. Return -1 if the number should be skipped. extract_nun("xx123$ 2, 5) 321 >>> # add Doctests here and in, $', 2, 99 be skipped pass

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions