Write a function called first it is passed a parameter x


Solution must be recursive. You are not allowed to use loops, or use the Python "in" operator.

PYTHON

Write a function called first. It is passed a parameter x, that may or may not be a list; if is x is a list it may contain other lists. The fuction should return the first non-list object in x.

In other words, first should return x in some cases, or x[0], x[0][0], x[0][0][0], etc.

def first(x):

>>> first(1)

1 >>> first([1,1])

2 >>> first([[3,1],2])

3 >>>first([[[[[[[4]]]]]], 1, 2, 3])

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a function called first it is passed a parameter x
Reference No:- TGS02926608

Expected delivery within 24 Hours