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:

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:

>>> 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
Get step-by-step solutions from verified subject matter experts
