0
What is another method?
Longest Word Given a text as input, find and output the longest word. Sample Input this is an awesome text Sample Output awesome Longest Word My solving: txt = input() v=txt.split() print(max (v,key=len)) What is another decision could be? may be more manule, not via max?
9 Respostas
+ 2
You may try something like this
txt = input().split()
longest = txt[0]
for word in txt:
if len(word) > len(longest):
longest = word
print(longest)
+ 2
Askar Kondybaev ,
it could also be done by using sorted() with key= len, but i think this is not what you wanted.
txt = "this is major tom to ground control".split()
print(sorted(txt, key=len)[-1])
to learn the basics, the sample from Simba is a good choice.
happy coding!
+ 2
Iris Salvation
This is learning platform so it would be better if you ask your programming problem.
+ 1
Simba, i think it is the best original solving.
0
Actually there no method that is follow from studied materials of "More Types" (Phyton Core) topic.
0
Amir javadikia
What is the difference between your code and shared code with question?
Your example is same as his example..
0
Ok i deleted it
0
- 1
Pls am new here can I make new friends