0
Onto the longest word project, it passed all cases except 4 so I didn't pass it... Help? Code is below.
txt = input() words=txt.split(" ") #your code goes here long_word_len =len(words[0]) for i in words: word_len=len(i) if word_len>long_word_len: long_word_len=word_len current=i print(current)
2 Antworten
+ 4
Try to think what will happen in your code if the first word, that is words[0], is the longest
+ 2
Aside from XXX has given, you may also want to declare that "current" variable first outside the for loop so it would also have a default value like long_word_len.