I have a list List1 = new list(Of String) from {“John”,“David”,“Miller”,“John”,“Miller”,“Mary”,“John”}
The output should like
John: 3
David: 1
Miller: 2
Mary: 1
My logic was to have a for-each loop to parse List1 and add distinct elements to a new list List2 and each time check List2 if the element exists and if so increment a counter, but somehow couldnt get this flow in uipath.
Could somebody help verify if the above logic is correct and if so help me with the flow to achieve this.
So the solution you provided was moving the list items to dictionary and displaying them, which is excellent. On the same lines I am trying to do is below
Parse through each of the above element in list1 using for each
Within body of for-each, check if List2.Contains(item)
If true, have a counter and increment it
If false, add to collection and set counter to 1
Finally at the end another for each to parse List2 and print the element followed by its count of occurance for eg: John 3 Terry 2 Mike 1
I am able to get the contents into List2, but the count doesnt seem to come correctly. secondly do you think i should use diff indices in each for loop like item1 and item2?
What do you think about the above steps, are the okay