标签:blog 提升 logs set tps sort color 去重 重复
每天一习题,提升Python不是问题!!有更简洁的写法请评论告知我!
https://www.cnblogs.com/poloyy/category/1676599.html
‘‘‘ 问题1.对列表a 中的数字从小到大排序 问题2.排序后去除重复的数字 ‘‘ a = [1, 6, 8, 11, 9, 1, 8, 6, 8, 7, 8]
# 非算法方案 a = [1, 6, 8, 11, 9, 1, 8, 6, 8, 6, 8] a = sorted(a) a = set(a) a = list(a) print(a) # 算法方案 a = [1, 6, 8, 11, 9, 1, 8, 6, 8, 6, 8] for i in range(0, len(a) - 1): for j in range(0, len(a) - 1 - i): if a[j] > a[j + 1]: a[j], a[j + 1] = a[j + 1], a[j] a = set(a) a = list(a) print(a)
标签:blog 提升 logs set tps sort color 去重 重复
原文地址:https://www.cnblogs.com/poloyy/p/12539786.html