+ 1

What is this?

txt = input() problem = max(txt.split(), key=len) print(problem ) What is "key=len"?

9th Jan 2021, 5:56 AM
Kovalov Evgen
Kovalov Evgen - avatar
1 Respuesta
+ 2
max() function in python takes three arguments. 1. The Iterable (String, list, tuple...) 2. The default value 3. The key Now in your example: The Iterable is a list of strings And the key defines the function that is applied to each item in the Iterable so here len() is the function used and now each item is compared on the basis of length ex: input : some random string output : random
9th Jan 2021, 6:19 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar