Remove an element from list

Hi, I wonder can I remove an element from array list? I’ve been using foreach function for a list. And then, I need to remove that element from the list. How to do this?
Thank you for your answer(s)!

Hello @wilhamanto
Could you please provide more details? Do you use RPA Express? Is it some custom script or your bot task?

Hello,

I have two lists as such:
List A: [A,B,C]
and
List B: [A_100, A_101, A_102, B_101, B_102, B_103, C_100,C_101, C_102, C_104]
then I meant to process for each element in list A, Split every element in List B by “_” then type the second split if the first split match the element processed. The problem is, every element in list A checks ALL element in List B, this leads to a problem if I have a lot of List B, and I figures I can shorten the process by removing the element of list B after typing the numbers. And I found this:


and guessing it can be done by that. However I don’t know the usage. Is my guessing true or is there any other method?

UPDATE: I managed to remove element processed, however, it’s still failed because it removed the wrong element number. Because you see, everytime an element is removed all element below it will change number hence the wrong removal. So the problem now is removing the RIGHT element each time.

UPDATE: My custom script cannot accept a list defined from outside itself. My script is as such:
image
variable element_number should be constant as long as the element processed is true. The update before this managed to remove the element when I add line below the list_trial.remove line:
list_trial = list_trial
however it actually processed THE SAME LIST as before the element removed, hence the result list is not what I expected to be. How can I define the list to process the new list after removed element?

UPDATE: I think I found (partly) how to do it. First, I create 2 EXACT SAME list, then as I process for each element in the first list, I remove the element processed in second list via custom script if the element match the variable I wanted. Then when the process ends, I set constant value null to the first list (emptying the list) and set expression value the second list to the first list. This way, the flaw will be first process will take the longest time as it will check every element in its original state.

Thank you, I think this thread can be closed. Unless, if someone can show more effective way.

1 Like