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
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