0

Is there a way to do the following without a forloop?

list = ['https:', '', 'store.playstation.com', 'chihiro-api', 
        'viewfinder', 'BR', 'pt', '999', 'UV0004-NPVA17938_CN-0000000000029839'
        ]
get_max_lengthed_item(list)
==> 'UV0004-NPVA17938_CN-0000000000029839'
David542
  • 101,766
  • 154
  • 423
  • 727

1 Answers1

2

You can use the key attribute of max function.

max(list, key=len) 
Bhargav Rao
  • 45,811
  • 27
  • 120
  • 136
Juan Lopes
  • 9,861
  • 2
  • 24
  • 42