练习python,,[Python]代码de


[Python]代码

def sumTwoLargest(lst):    a = findLargest(lst)    b = findSecond(lst)    sum = a+b     print sumdef findLargest(lst):    a = lst[1]            for i in lst:           if i > a:            a = i    return adef findSecond(lst):    a = findLargest(lst)    b = lst.index(a)    lst.pop(b)    c = findLargest(lst)    return c 

[Python]代码

def reverse(lst):    # write your solution code here    b = 1    #dict = (lst)    for i in lst:         if b > len(lst)/2:            break        a = i        print a        #print len(lst)-b        lst[b-1] = lst[len(lst)-b]        print i        lst[len(lst)-b] = a        b += 1    return lst

评论关闭