经典的Python练习题目【多测师_王sir】

#coding=utf-8
"""
===========================
Author:多测师_王sir
Time:2020-09-08 13:51
Wechat:xiaoshubass
website:www.duoceshi.cn
===========================
"""

#返回其中第二大的值
def return_second():
    list1 = []
    #列表解析式把元组转换为列表
    [list1.append(i) for i in (10,3,2,10,-2,0)]
    list1.sort(reverse=True)  #降序排序
    for i in range(len(list1)):  #0
        for j in range(i+1,len(list1)):
            if list1[i] == list1[j]:
                return (list1[j+1])
            else:
                return (list1[j])

print(return_second())

 

posted @ 2020-09-09 15:21  多测师_树哥  阅读(222)  评论(0编辑  收藏  举报