Question: The function substring determines the position in a given string where another string occurs as a zubstring. xample, the string ab occurs in the string

 The function substring determines the position in a given string where
another string occurs as a zubstring. xample, the string "ab" occurs in

The function substring determines the position in a given string where another string occurs as a zubstring. xample, the string "ab" occurs in the string "abab" at positions 0 and 2. The function takes two parameters: str which is the given string and s which is the substring to look for. The function returns a list of the positions in str in which s occurs. The function is syntactically correct but has four (4) incorrect lines of code which contain logic errors that prevent it from computing correctly. In the following questions, you will choose the answer to the question on particular lines of code - how they should be corrected or whether they are correct as they are; remember, only 4 lines are incorrect. Examples of a main program that uses the function, when it is correctly implemented, and sample output are also provided. Punction to determine positions of a substring in another string def substring (str,s): posns = 1 for i in range (len (str)-len(s) +1): done - False while 3

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!