GrKa
November 12, 2021, 9:36pm
1
Hi!
I have a list of strings: list1 = (“1”, “1”, “2”) and list2 = (“1”, “2”). Now I would like to get the value (“1”) as result, which is the value which is added to list1.
Thinking of counting the number of the unique elements and compare these values. Is there an easier solution?
Thank you in advance and kr,
GrKa
Yoichi
(Yoichi)
November 12, 2021, 11:35pm
2
Hi,
One of the easiest way, remove items which exists List2 from List1 as the following.
If you keep values of List1, please copy it in advance.
note: ArgumentType of ForEach is String
if you have large list, it’s better to use Invoke Code activity.
Regards,
1 Like
Hi
Welcome back to uipath forum
Use a simple assign activity like this
Final_list = list1.Except(list2)
Where Final_list is a variable of type
System.Collections.Generic.List(of Int32)
Cheers @GrKa
4 Likes
Hi @Palaniyappan Can this be achieved where the lists are of type string?
Thank you
ppr
(Peter Preuss)
August 31, 2023, 10:37am
5
Yes,
But we do see, that it is deduplicating, Therefore we do get an empty list returned
An implementation keeping the duplicates and reducing by list occurence count could look like this:
But we also recommend to checkout the suggestion from @Yoichi given above
1 Like
Parvathy
(PS Parvathy)
August 31, 2023, 10:41am
7
Hi @GrKa
Assign two List Variables say List1 and List2 of datatype System.Collections.Generic.List(String).
List1= New List(of String) from {"A","B","C","D"}
List2= New List(of String) from {"B","D"}
Use For each loop to iterate through List1
Use an Assign activity and write the below syntax
currentItem=Item.ToString
Use an if activity and write the below condition
List2.Contains(Item)
Use an assign activity and create an variable ItemExists of datatype Boolean.
Use Log message to print the value.
Note: Attached workflow for your reference
Sequence7.xaml (10.1 KB)
Hope it helps!!
Regards,
Check out this thread for more information.
Hi @rayz1503
Assign two List Variables say List1 and List2 of datatype System.Collections.Generic.List(String).
List1= New List(of String) from {"A","B","C","D"}
List2= New List(of String) from {"B","D"}
Use For each loop to iterate through List1
Use an Assign activity and write the below syntax
currentItem=Item.ToString
Use an if activity and write the below condition
List2.Contains(Item)
Use an assign activity and create an variable ItemExists of datatype Boolean.
Use Log message to…
Regards,