+ 2
Python Core - ex 62 - Longest Word
Hi all, what is wrong here, for some reason in Python 3 it works but with their taste case’s it always fails and it takes the las word from the list txt = input() #your code goes here new_bla = txt.split(" ") i = 0 ln = ['t'] while i < len(new_bla): if len(new_bla[i]) > len(ln): ln.clear() ln.append(new_bla[i]) i=i+1 print(ln)
4 Antworten
+ 3
Samuel Fodorean ,
you have been very close to a correct solution. so i would like to present you the 2 issues of your code. you can fix it, and it will run.
>> i find it important for you to know why your code has not been passed the test cases. see the slightly reworked code in the file:
https://code.sololearn.com/cGm1ony5cWY0/?ref=app
+ 1
Thanks
0
Print this in ex:
txt = input()
# your code goes here
list = max(txt.split(" "), key = len)
Print(list)
0
Thanks