获取最小长度元素

获取最小长度元素

一、列表list

example:

lists = ['flower','for','flight']
min1 = min(lists, key=len)

二、元组tuple

example:

tup = ('flower','for','flight')
min1 = min(tup, key=len)

三、集合set

example:

set1 = {'flower','for','flight'}
min1 = min(set1, key=len)

posted on 2023-10-09 18:15  胡萝卜&  阅读(21)  评论(0)    收藏  举报

导航