Home / Expert Answers / Computer Science / write-a-function-called-substring-that-takes-two-parameters-a-string-and-an-integer-the-function-pa996

(Solved): Write a function called substring that takes two parameters: a string and an integer. The function ...



Write a function called substring that takes two parameters: a string and an integer. The function should return a list of al

Write a function 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 look something like this:. \( \gg \) subS?tring ('alphabet' , 3) ['alp', 'lph', 'pha', 'hab', 'abe', 'bet'] >>> subString('alphabet' ,6) ['alphab', 'lphabe', 'phabet'] >>> subString('alphabet', 1) ['a', 'l', 'p', 'h', 'a', 'b', 'e', 't']


We have an Answer from Expert

View Expert Answer

Expert Answer


Steps to write the code: 1. subString function 2. create an empty list as result 3. iterate through all indices of the string 4. get a sub string of l
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe