开发者

Suggestions for improving this little piece of code?

Any suggestions to improve this little piece of code? It works, but there must be a better way of doing it. Especially the first two lines, I have a bunch of them. Can't 开发者_JS百科I merge the two somehow?

for iso in set(BAR_Items):
    if iso+YEAR in heights: 
        mylist.append(heights[iso+YEAR])
mylist.sort()
cut = percentile(mylist, POS)

Thanks


The first three lines can be written concisely as a list comprehension.

mylist += [heights[iso+YEAR] for iso in set(BAR_Items) if iso+YEAR in heights] 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜