I have a list of 5 words in those, i should find the largest word using UiPath. Can anyone help me please.
- Create a variable named “largestWord” of type String and initialize it with an empty value.
- Create an array variable named “wordsArray” of type String and assign the values “Apple”, “Cat”, “Monkey”, “Lion”, and “Rat” to it.
- Add a “For Each” activity to iterate over the “wordsArray” variable. Configure it to iterate over the array.
- Inside the loop, add an “If” activity. Set the condition to
word.Length > largestWord.Length
, where “word” represents the current word from the array. - In the “Then” section of the “If” activity, add an “Assign” activity. Assign the value of “word” to the “largestWord” variable.
- 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)
@sandhyareddy
wordList = New List(Of String) From {“apple”, “banana”, “grape”, “orange”, “kiwi”} for eg,
largestWord = wordList.OrderByDescending(Function(word) word.Length).FirstOrDefault()
hope it helps
Assign:
largestWord = “”
words = {“Apple”, “Cat”, “Monkey”, “Lion”, “Rat”}
For Each:
word in words
If:
word.Length > largestWord.Length
Assign:
largestWord = word
Write Line:
"largestWord: " + largestWord
Try this linq query:
result = words.OrderByDescending(Function(d) d.Length).First()
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.