1.I came across this code: Python Recursion and list
def search(lst, key):
if not lst: # base case: list is empty
return False
elif lst[0] == key: # base case: current element is searched element
return True
else: # recursive case: advance to next element in list
return search(lst[1:], key)
Can the recursive search start from the first element as search(lst[0:],key)
? Why is the first element treated separately?
2.Why is this a recursion?
selfref_list = [1, 2, 3]
selfref_list.append(selfref_list)