Güngör Budak's Blog

Bioinformatics, web programming, coding in general

Python: Get Longest String in a List

Share Tweet

Here is a quick Python trick you might use in your code.

Assume you have a list of strings and you want to get the longest one in the most efficient way.

>>>l=["aaa", "bb", "c"]
>>>longest_string = max(l, key = len)
Share Tweet


Please start a discussion down below or send me an email!