Tom Ritchford
Apr 2, 2023

--

What about short_one = (a, b)[len(a) > len(b)]?

😎

All right, I admit it’s obscure. But what about this one?

short_one = max(a, b, key=len)

That’s actually clearer as to your intention, and will extend to unlimited numbers of arguments.

Fun article so far, expect claps.

--

--

Tom Ritchford
Tom Ritchford

Responses (1)