I want to find the largest word. Can anyone help me please

I have a list of 5 words in those, i should find the largest word using UiPath. Can anyone help me please.

Hi @sandhyareddy

  1. Create a variable named “largestWord” of type String and initialize it with an empty value.
  2. Create an array variable named “wordsArray” of type String and assign the values “Apple”, “Cat”, “Monkey”, “Lion”, and “Rat” to it.
  3. Add a “For Each” activity to iterate over the “wordsArray” variable. Configure it to iterate over the array.
  4. Inside the loop, add an “If” activity. Set the condition to word.Length > largestWord.Length, where “word” represents the current word from the array.
  5. In the “Then” section of the “If” activity, add an “Assign” activity. Assign the value of “word” to the “largestWord” variable.
  6. After the loop, the “largestWord” variable will contain the largest word among the given words.

Hey @sandhyareddy , Try this

Assign wordsList = userInput.Split(" "c)
|— For Each word In wordsList
| |
| |— If word.Length > largestWord.Length
| | |
| | |— Assign largestWord = word
| |
|— Message Box (largestWord)

wordList = New List(Of String) From {“apple”, “banana”, “grape”, “orange”, “kiwi”} for eg,
largestWord = wordList.OrderByDescending(Function(word) word.Length).FirstOrDefault()

hope it helps


largestWord = “”
words = {“Apple”, “Cat”, “Monkey”, “Lion”, “Rat”}

For Each:
word in words

word.Length > largestWord.Length
largestWord = word

Write Line:
"largestWord: " + largestWord

Hi @sandhyareddy

Try this linq query:
result = words.OrderByDescending(Function(d) d.Length).First()

1 Like

Hi @sandhyareddy

Use the below workflow

I got the output is : Monkey (It was the Largest word)
I have attached the workflow below for your reference.
Browser_Practice.xaml (12.3 KB)

Hope it helps!!


I have uploaded the file
Refer this and if you have any doubts don’t hesitate to ask
test.zip (954.1 KB)

Happy Automation!

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