Question: PYTHON 1. Write a function subStrings that takes a list of strings as an argument. It returns a list that contains every string in the

PYTHON

1. Write a function subStrings that takes a list of strings as an argument. It returns a list that contains every string in the list that is a substring of the one that precedes it (comes immediately before it in the list). If the list is empty or contains only one string, the function doesn't print anything. Note that this means that the function will never print the first item in the list since it has no predecessor in the list. The following shows several sample runs of the function:

>>> subStrings(['apple','app','pp','orange','range','ra'])

['app', 'pp', 'range', 'ra']

>>> subStrings(['apple','app','pp','orange','range','pineapple'])

['app', 'pp', 'range']

>>> subStrings(['apple'])

[]

>>> subStrings([])

[]

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!