Returning longest word in list of words

try with this block from "list utility" library: "#" is a counter (index)
untitled script pic

I will experiment with it thanks for the tip

True! The script below uses O(n) computing time; because it uses built-in functions working on a list it’s typically over 5 times faster than an algorithm working on individual words, which may count if the input text is really long:


increasing.xml script pic (4)
Should this script not return "love" 3 times rather than blanks fields?

If you select single stepping (remember to move slider across to the left)

image

and then click on this extracted version of your block

untitled script pic (61)

and then click on the yellow step icon

image

then I think you'll be able to see where things are going wrong once your repeat loop is processing the 3

oh yeah! that's a great tool for checking where i'm wrong thanks! sorted it now

Wouldn’t that latest version of the script report 4x “love”?

A little detail: I recommend SPLIT BY WORD rather than SPLIT BY (space). Then you don't have to worry about multiple spaces between words or spaces at the beginning or end.

yeah, if abuzars keep this logic, it will return:
image
But for now, this script doesn't work...

Another thing: Test your script with this sentense...

I 3 love 3 you

I think if you keep this script, you will get :
I love love love love love love love you
(because (index of 3) + 1)

the block "index of" isn't the solution...

this is the way to the solution:

or

also test your script with these sentenses
I 3 2 love you
I love you 2
I 1 love you
I 0 love you (zero)

this works:

Untitled script pic

With this block (not the longest word block):

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.