Question: Using Python Let list1 and list2 be two lists of integers. We say that list1 is a sublist of list2 if the elements in list1

Using Python

Let list1 and list2 be two lists of integers. We say that list1 is a sublist of list2 if the elements in list1 appear in list2 in the same order as they appear in list1, but not necessarily consecutively. For example, if list1 is defined as [15, 1, 100] and list2 is defined as [20, 15, 30, 50, 1, 100] then list1 is a sublist of list2 because the numbers in list1 (15, 1, and 100) appear in list2 in the same order. However, list [15, 50, 20] is not a sublist of list2. Implement function sublist() that takes as input lists list1 and list2 and returns True if list1 is a sublist of list2, and False otherwise. >>> sublist([15, 1, 100], [20, 15, 30, 50, 1, 100]) True >>> sublist([15, 50, 20], [20, 15, 30, 50, 1, 100]) False

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!