l = ("xxxxxxxxx", "yyyy","zz") print(max(l, key=len))
First of all, you do not have a list, you have a tuple. however, this code will work for any sequence; both lists and tuples are sequences (as well as strings, sets, etc.). Thus, the max function accepts the key argument, which is used to sort the iteration elements. Thus, of all the elements l , one that has the maximum length will be selected.
source share