lst = [3, 6, 1, 8, 1, 9 , 8,10,21] min=lst[0] max=lst[0] mi=lst[0] ma=lst[0] for i in lst : if i>max: max=i if min>i: min=i if i%2==0: if mi>i: mi=i elif mi%2!=0: mi=i elif ma<i: ma=i print(min,max,mi,ma)
运行结果