Question: WRITTEN IN PYTHON PLEASE :) b) lookupva12 (tL, k) Write a function lookupVal2 that takes a list of tuples (tL) and a key k as

WRITTEN IN PYTHON PLEASE :)WRITTEN IN PYTHON PLEASE :) b) lookupva12 (tL, k) Write a function

b) lookupva12 (tL, k) Write a function lookupVal2 that takes a list of tuples (tL) and a key k as input. Each tuple in the input list includes an integer index value and a dictionary. The index in each tuple represent a link to another tuple in the list (e.g. index 3 refers to the 4th tuple, i.e., the tuple at index 3 in the list) lookupVal2 checks the dictionary in each tuple in tL starting from the end of the list and following the indexes specified in the tuples. For example, assume the following [ (0,d0), (0,d1), (0,d2), (1, d3), (2,d4), (3,d5), (5,d6) ] -10% 2 The lookupVal2 function will check the dictionaries d6, d5, d3, d1, d0 in order (it will skip over d4 and d2) The tuple in the beginning of the list will always have index 0 It will return the first value found for key k. If k is couldn't be found in any dictionary, then it will return None. For example: 2 = [ ( 0, { "x'' : O, '' y '' : True, '' z'' : "zero" } ) , (1, ("y":False)), (1, ("x":3, "z":"three"]) lookupVal2 (L2, "x") returns1 lookupVal2 (L2, "y") returns False lookupVal2 (L2, "z") returns "zero" lookupVal2 (L2, "t") returns None (Note: I suggest you to provide a recursive solution to this problem Hint: Define a helper function with an additional parameter that hold the list index which will be searched in the next recursive call.)

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!