Güngör Budak's Blog

Bioinformatics, web programming, coding in general

Python: Get Longest String in a List

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)