How to find the length of the shortest string in a list of strings with Python

2 Answers

0 votes
lst = ['python', 'php', 'java'] 

lenn = min(len(item) for item in lst) 

print(lenn)



'''
run:

3

'''

 



answered Jan 21, 2020 by avibootz
0 votes
lst = ['python', 'php', 'java'] 

lenn = len(min(lst, key = len)) 

print(lenn)



'''
run:

3

'''

 



answered Jan 21, 2020 by avibootz
...