0
Why am I not able to sort the resultant list??
def func(str): return len(str) a = input("Enter:").split(" ") p = list(zip(a,list(map(func,a)))) p.sort(reverse=False) print(p)
7 odpowiedzi
+ 1
In that case your code is much more complicated than needed. You can just take an input, make it a list, and print out the longest word (using the max() function), and the length of it (so you will need len(max(input))). Try that and I'll help if you need it
+ 1
Solomoni Railoa that is a good way of doing it, however I believe that it can be simplified further. Here is the link to my explanation through it: https://code.sololearn.com/cYAnMGomH9VJ
And yes it is possible to take out the quotation marks but it is very long and unnecessary
0
It is sorting correctly. Maybe it's not sorting as you want, how do you want it to sort?
0
Here's the task:
I will enter a sentence and i need to return the max length in it along with the word
Ex:
Input:
"I love programming"
Output:
(Programming,11)
0
Thank you 😀