I have a list:
testList={{"a","b 3","cd","ef 23"},{"z 12","y","x"}}
and wish to obtain
resultList={{"b 3","ef 23"},{"z 12"}}
...where I have deleted list items which do not include (string representations of) numbers. My thoughts on how to do this lead to the opposite of elegant code. Any ideas gratefully received.
Thank you for your responses!
I have a related question. Using the following list:
testList2={{"a","b 3","cd","ef 23"},{"z 12","y","x"},{"z","y"}}
I wish to keep list members that contain string representation of numbers and delete list members that don't, which will give:
resultList2={{"a","b 3","cd","ef 23"},{"z 12","y","x"}}
- in this case, the third list item in testList2 gets dropped because its elements don't contain a string representation of a number.
Again, thanks for thoughts.
Comments
Post a Comment