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

2 Answers

0 votes
lst = ['c', 'python', 'php', 'java', "c#"] 

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

print(lenn)



'''
run:

6

'''

 



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

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

print(lenn)



'''
run:

6

'''

 



answered Jan 21, 2020 by avibootz
...