How to find the shortest string in a list in Python

后端 未结 6 688
星月不相逢
星月不相逢 2020-12-02 19:53

This seems like a pretty simple problem, but I\'m looking for a short and sweet way of doing it that is still understandable (this isn\'t code golf).

Given a list of

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 20:28

    arr=('bibhu','prasanna','behera','jhgffgfgfgfg')
    str1=''
    
    #print (len(str))
    for ele in arr:
        print (ele,ele[::-1])
        if len(ele)>len(str1):
            str1=ele
        elif len(ele)

提交回复
热议问题