Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE/IT 107L Lab 8: Recursion Exercise 6.3 (nested.py) A nested list is a list that contains one or more lists as elements. For example, the

image text in transcribed
CSE/IT 107L Lab 8: Recursion Exercise 6.3 (nested.py) A nested list is a list that contains one or more lists as elements. For example, the list [1,2,3, [50,60,70], [ (8888],999],10] contains 6 elements. . The first three elements are integers. . The fourth element is a list: [50,60,70] . The fifth element is also a list. This list has two elements: another list (t8888],999]) and 10 The following functions should have recursive definitions. 1. Write a function named element of that returns True if the first argument is within any of the sub-lists of the nested list and False otherwise 2. Write a function named filter.by.depth that takes two arguments: an integer repre- senting depth and a nested list. It should remove all sub-lists that are more than depth deep $ 18 2 nested py $ python3 >>> import nested s >>> nested.element of (5, [1,2,3,4,5,6,7]) 6 True >>>nested.element of (7, [1,2, [3,4, [5,6]1, [7]) s True >>>nested.element.of (77, [1,2, [3,4, [5,6]), [7]]) o False >>> nested, filter-by-depth(0, 12 13 >>> nested.filter_by_depth(1, 14 [1,2,3)] is >>> nested.filter_by_depth(5, [1,2,3]) [1,2,3]) [1,2,3]) 17 >>>nested.filter_by_depth(2, [1,2, [3,4, [5,61), [7]]) Hint: use the type function to check if an element is a list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

b. Explain how you initially felt about the communication.

Answered: 1 week ago

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago