Python Forum

Full Version: Solving a nested list
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have to write a function that takes an integer nested list and integer parameters(nl, i). The function has to determine whether i is contained in the nested list nl and return True.
I have made the following code, but I know I am missing something;

def exercise5(nl, i):
   if type(i)==type(1):
      return True
print(exercise5( [[9, 4, 5], [3, 8]], 3))
Could someone help with finalizing the code?
Finalizing is an understatement. Your function returns True if i is an int and None otherwise. This is unrelated to the question.
Yeah, I know that there is a lot to do on the code, but I don't know what to do. Could you help me make it?
SNIP

try this code, cant think other than to recurse the function and perform the task as u wish