← Back to challenges

Is One List a Subset of Another?

PythonHardarraysloopsvalidation

Instructions

Create a function that returns True if the first list is a subset of the second. Return False otherwise.

Examples

is_subset([3, 2, 5], [5, 3, 7, 9, 2]) ➞ True

is_subset([8, 9], [7, 1, 9, 8, 4, 5, 6]) ➞ True

is_subset([1, 2], [3, 5, 9, 1]) ➞ False

Notes

Both lists will contain only unique values.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Halve and Halve Again