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

1. a.) Write a function (in python) called subString that takes two

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:

parameters: a string and an integer. The function should return a list

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

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!