- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Remove word from list
Hi! I am trying to remove the word "none" from my lists ( which is variable according to the data input), but after running the script I see no changes in my output. Do you guys have any suggestion on how I can improve my code?
unique= Associative Array(Data) << Get Keys;
show(unique); // output- unique= {" BGG", " BSG", "None"}
Number= nitems(unique);
for( i= 1, i >= Number, i++,
if (unique[i]== "None",
remove from(unique,unique[i]);,
);
);
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Remove word from list
Here is how you want to handle your issue. By working backwards down the list, you do not get the reference to the list incorrect because of deleting members of the list.
unique = {" BGG", " BSG", "None"};
For( i = N Items( unique ), i >= 1, i--,
If( unique[i] == "None",
Remove From( unique, i, 1 ),
)
);
Show( unique );
Jim
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Remove word from list
Here is how you want to handle your issue. By working backwards down the list, you do not get the reference to the list incorrect because of deleting members of the list.
unique = {" BGG", " BSG", "None"};
For( i = N Items( unique ), i >= 1, i--,
If( unique[i] == "None",
Remove From( unique, i, 1 ),
)
);
Show( unique );
Jim