max()
with len()
as the key
to return the item with the greatest length.def longest_item(*args): return max(args, key = len)
longest_item('this', 'is', 'a', 'testcase') # 'testcase' longest_item([1, 2, 3], [1, 2], [1, 2, 3, 4, 5]) # [1, 2, 3, 4, 5] longest_item([1, 2, 3], 'foobar') # 'foobar'
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️