I am trying to remove items within a list based on the list of items from another list (in which the items within are slightly different).
It is like a "wildcard" search in which I end up using endswith
to check as follows:
main_ctrls = [
"main_start_ctrl",
"main_global_ctrl",
"main_local_ctrl",
"main_path_ctrl"
]
toy_ctrls = ['toyBody:main_start_ctrl', 'toyBody:main_global_ctrl', 'toyBody:leg_ctrl', 'toyBody:main_local_ctrl', 'toyBody:main_path_ctrl']
for index, ctrl in enumerate(toy_ctrls):
if ctrl.endswith(tuple(main_ctrls)):
#toy_ctrls.remove(ctrl)
# del toy_ctrls[index]
# toy_ctrls.pop(index)
print toy_ctrls
# Returns : ['toyBody:base_global_ctrl', 'toyBody:base_path_ctrl', 'toyBody:leg_ctrl']
However, as seen in the above code, I have tried .remove()
, del
, .pop()
and it returns the same output (3 items in the list) instead of the 1 item - ['toyBody:leg_ctrl']
that I am expecting.
Could someone kindly advise?