Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

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

Step: 3

blur-text-image

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions