Hi, trying to learn recursion right now.
I'm trying to write this program where it will tell the position of the letter if found in the list. I'm trying to not use the in function or the .index() function to find the position.
I got everything except the position. Any help would be helpful.
My current code is:
def position(lst,pos): if lst == : return False if lst == pos: #this is where i'm stuck, don't know what to change return True else: return position(lst[1:], pos) #testing l = ['1', 2, 3] print position(l, '1') #this would output 0 print position(l, '4') #this would output False
For this other one, trying to make a recursive function of selection sort.
I'm trying to extract the maximum instead of the minimum and append it to a recursively sorted sublist, but I'm not sure how to do it.
Trying to do this without using a return value.
def selectionsort(a): if len(a) <= 1: return a else: #stuck here selectionsort(a[:-1 .append()
Ty for any help.