0

Please 🙏 🙏 🙏 I need to output city that has the minimum and maximum number of letters in a word

s = list (map (str, input())).split() print(s) print (f' {min(s, key = len)}\n{max(s, key = len)}') https://code.sololearn.com/cf1v7StsW1Za/?ref=app

6th Nov 2022, 6:39 PM
Murrr
2 Réponses
+ 12
murrr , when we use the input() function to take a text that has to be used as individual strings, we can use .split() directly with the string. using split() creates a list of strings by default. we don't need map() to convert each of the words to a string, since input() returns a string by default. there is also no need of list() function. we can do: s = input().split() print(f'{min(s, key = len)}\n{max(s,key = len)}')
6th Nov 2022, 8:01 PM
Lothar
Lothar - avatar
+ 1
Thanks a lot !!!
6th Nov 2022, 10:29 PM
Murrr