For the purpose of this problem a nested list is a list


For the purpose of this problem, a nested list is a list that may contain a mix of nested lists and integers. A particular value occurs in a nested list if it is an element of the list or occurs in a nested list that is an element of the list.

Design a function search_nested_list(x, nested_list): that returns True if x occurs in nested_listand False otherwise.

For example:

  • If x = 1, and nested_list = [3, 5, [3, 5, 1], 1], search_nested_list(x, nested_list) should return True.
  • If x = 5, and nested_list = [[3], 2, [3, [[5], 1], 1]], search_nested_list(x, nested_list) should return True.
  • If x = 4, and nested_list = [[3], 2, [3, [[5], 1], 1]], search_nested_list(x, nested_list) should return False.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: For the purpose of this problem a nested list is a list
Reference No:- TGS02815621

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)