Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. a.) Write a function (in python) called subString that takes two parameters: a string and an integer. The function should return a list of

1. a.) Write a function (in python) called subString that takes two parameters: a string and an integer. The function should return a list of all substrings of the string of the specified length. You may use the string slice function provided by python. The output of your function should like something like this:

image text in transcribed

b.) Given the function that you wrote in part 2 above, write another function that calls the subString function and prints all of the substrings of any length of a given string. Do not print substrings of length 0. Start with substrings of length 1. NOTE: Even if you are not able to complete part 2 above, you should be able to provide code for part 3 here.

Your output will look something like this:

image text in transcribed

>>> substring('alphabet',3) ['alp', 'Iph', 'pha', 'hab', 'abe', 'bet'] >>> substring('alphabet',6) ['alphab', 'lphabe', 'phabet'] >>> substring('alphabet',1) ['a', 'l', 'p', 'h', 'a', 'b', 'e', 't'] >>> allSubStrings('alphabet') ['a', 'l', 'p', 'h', 'a', 'b', 'e', 't', 'al', 'lp', 'ph', 'ha', 'ab', 'be', 'et ', 'alp', 'lph', 'pha', 'hab', 'abe', 'bet', 'alph', 'lpha', 'phab', 'habe', 'ab et', 'alpha', 'lphab', 'phabe', 'habet', 'alphab', 'lphabe', 'phabet', 'alphabe' 'lphabet'] >>> allSubStrings('hello') ['h', 'e', 'l', 'l', 'o', 'he', 'el', 'll', 'lo', 'hel', 'ell', 'llo', 'hell', ello'] >>>

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_2

Step: 3

blur-text-image_3

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

Students also viewed these Databases questions

Question

What is the size of that same Mg 2+ ?

Answered: 1 week ago

Question

3. Evaluate a Web-based training site.

Answered: 1 week ago