Reputation: 63
I am a list which is - ['','','','Some-Value','',''] , I am trying to remove all the null/empty values from list so that the final result be ['Some-Value'].
Below is the code which I tried but so no luck so far
${list_size} = Get Length ${list}
For ${index} IN RANGE ${list_size}
${item} Get Form List ${list} ${index}
Run Keyword if '${item}' == '' Remove ${item} from list ${list}
enter code here
End
Can anyone help to solve this problem ? Thank you!
Upvotes: 1
Views: 2356
Reputation: 1242
Robot framework enables you to use Evaluate keyword, and than it is just a python problem. This code example produces the result you are looking for.
*** Variables ***
@{list_variable} ${empty} some text ${empty}
*** Test Cases ***
Replace a String
${cleared_list}= Evaluate [x for x in @{list_variable} if x]
Log ${cleared_list}
Upvotes: 3