Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The function allSubstring(str, 3) finds all the occurrences of one string in another and returns a list of positions where the second string s occurs
The function allSubstring(str, 3) finds all the occurrences of one string in another and returns a list of positions where the second string s occurs in the first string str, even if there are overlaps. For example, allSubstring("abab", "ab") will return [0, 2] and allSubstring("aaa", "a") will return [0, 1, 2]. The function needs to be completed as several lines have been omitted. Identify the number of the lines that are needed to complete the omitted lines in the code (vertical bars indicate where the line of code is indented). Complete the code by choosing the appropriate lines of code from the list of available lines (click on the attachment below for the list of available lines and the code to complete). List of Lines to Choose From: 1) found = True 2) found = False 3) if i == j: 4) if str[i== s(): 5) if str[i+1] == s[i]: 6) if str[i+j] == s[j] Code Segment to Complete: def allSubstrings(str,s): plst = 0 for i in range(0, len(str) - len(s) + 1): j = 0 found = True while i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started