[Tutor] about recursion code

Lin Jin jinlin555 at msn.com
Tue Dec 7 05:37:20 CET 2004


hello,tutors:
  i am working on the recursion of selection sort,and my code is:
def selection_sort(lst,start,end):
    """sort the lst from selection start to end"""
    if len(lst)==1:
        return lst
    elif lst=="":
        return ""
    else:
        return lst[:start]+selection_sort(lst,start+1,end)
a=[1,3,5,2]
b=1
c=3
print selection_sort(a,b,c)

but it seems not working when i call the function,anyone could tell me that 
what  i did wrong with my code?

_________________________________________________________________
ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£  http://www.hotmail.com  



More information about the Tutor mailing list