编辑代码


def listMax(list):    
    if len(list) == 0 :     
        return 0;
    else:
        temp = list[0];
        for item in list:
            if item > temp:
                temp = item;
        return temp;


list1 = [8, 3, 6, 5, 1, 5];
list2 = [8, 12, 14, 64, 30, 5];
list3 = [6, 42, 1, 33, 40];

if __name__ == "__main__":
    print(listMax(list1)); 
    print(listMax(list2)); 
    print(listMax(list3));