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
  • 104,438
  • 178
  • 489
  • 842

1 Answers1

2

You can use the key attribute of max function.

max(list, key=len) 
Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Juan Lopes
  • 10,143
  • 2
  • 25
  • 44