1.
CODE
lis1 = [10, 21, 30, 14, 5]
is_even = lambda x: x % 2 == 0
# using filter
lis2 = list(filter(is_even, lis1))
print(lis2)
2.
CODE
def is_list(p):
return isinstance(p, list)
def deepReverse(mylist):
result = []
for e in mylist:
if isinstance(e, list):
result.append(deepReverse(e))
else:
result.append(e)
result.reverse()
return result
print(deepReverse([1,2,[3,4,5],6]))
Get Answers For Free
Most questions answered within 1 hours.